Showing posts with label NSDictionary. Show all posts
Showing posts with label NSDictionary. Show all posts

Wednesday, August 1, 2012

Tips: How to find if NSDictionary has a key.



if ([[myDiction allKeys] containsObject:@"myKey"])
    NSLog(@"It contains myKey");



Thursday, June 28, 2012

Boolean in NSDictionary

You can store a bool value in NSDictionary as following



NSDictionary *aProperties=[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:@"myboolkey"];

 To retrieve a bool value from NSDictionary:

BOOL boolValue;
if([aProperties valueForKey:@"myboolkey"]) 
  boolValue =[[aProperties valueForKey:@"myboolkey"] boolValue];