I'm trying to check the existence of a key in a plist file in Xcode. This is the structure in my plast file. Root (dictionary) + - parent (key) - key 1 (boolean) - key 2 (boolean) - key 3 (boolean) - key 4 (boolean) + - parent 2 (Dictionary) - key 1 (boolean) - key 2 (boolean)
Now I have to check whether Key2 is present in parent1 or not? I tested NSDictionary but how can I do that?
Any suggestions on how to do this?
NSDRIVATION * dict = [NSDiction dictionary with contentofffile: @ "yours.plist"]; BOOL key 2Exists = [[Dick ObjectForcae: @ "Parent 1"] ObjectForcae: @ "Key2"]! = Zero;
For obvious zero
comparison, I sometimes use it because it makes the code more readable to me (it reminds me that The variable statement on the left is a boolean). I have also seen a clear "boolean cast":
BOOL key2Exists === [[dict objectForKey: @ "parent1"] objectForKey: @ "key2"];
I think this is a matter of personal priority.
Comments
Post a Comment