When using NSCoding and decoding values, is there a way to find out if a value exists for a given key? In other words, what I'm trying to do is ...
if([decoder valueExistsForKey:@"myKey"]) //valueExistsForKey is not a real method :( { NSInteger *myInt = [decoder decodeValueForKey:@"myKey"]; } else { //handle special case }
The problem is that I have old versions of documents in my application that donβt have a value of "myKey", and if they donβt have it, then 0 is used for myInt (what happens if you decode a nonexistent key) is not the behavior that I want. However, I cannot simply decode and check if myInt == 0, because it can be legal equal to 0.
Since the valueExistsForKey method does not seem to exist, how can I replicate this behavior?
MikeS source share