i am using label to display data from various string but if string is not giving any value i want to display nothing in label but hare in below code it is displaying “null” if no value is given by sting.
i don’t want to display null in label …. how can i solve it.
where_do_you_hurt.text = [NSString stringWithFormat:@"%@,%@,%@,%@",appdelegate.hurt_head,appdelegate.hurt_Arm,
appdelegate.hurt_leg,appdelegate.hurt_chest,appdelegate.hurt_Back];
For each value that you don’t want to have
(null)printed, you need to provide an empty string if the value isnil. You can do so like this:The
obj ? obj : @""means: if the object is not nil (obj ?) then pass the object (obj), otherwise pass the empty string (: @"").An alternative would be use to a mutable string and then do: