Does ObjC have something like in swift default value?
let a = b.name ?? "Empty"
I have an object with parameters and I have to check all parameters if they are not nil and if yes, set them to some default value.
Does ObjC have something like in swift default value?
let a = b.name ?? "Empty"
I have an object with parameters and I have to check all parameters if they are not nil and if yes, set them to some default value.
This is Ternary operator in most of the programming language. You can find details on this here - What does the question mark and the colon (?: ternary operator) mean in objective-c?
In Objective C ?? replaced by ?: Do follow the link or here is a short example if this comes to your help -
NSString *msgFullString = [NSString stringWithFormat:@"Message: %@", msg ? : @"Unknown error"];
You can also check if value exist or not using if(b.name). it will return true if b.name has a value or false if b.name is nil.
Hope this helps....