I work in the IPhone SDK and am pretty new to objective-c. I am currently working with NSUserDefaults to save and restore settings in my IPhone application. To save the created classes, I will encode them in the form of a dictionary, and then save the NSdictionary.
My problem is that I cannot find a reasonable way to store a non-value (IE class variable that is nil) in a dictionary in a reasonable way. To be more specific, let's say I have the Dog class, and it got the tail color NSString *. Suppose I'm trying to save an instance of a dog class without a tail, so the tail for this instance is zero. What is a smart way to keep a dog as a dictionary? This will not allow me to save nil in NSdictionary. @ "is not very good, because if I do if (@" "), @" "is true. I would like it to be false as zero.
Hope my question makes sense and thanks for your help!
Ethan source
share