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];

No comments:

Post a Comment