Well, for integers I would use NSNumber
. But YES and NO aren\'t objects, I guess. A.f.a.i.k. I can only add objects to an NSDictionary
, right?
Try this:
NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
[dic setObject:[NSNumber numberWithBool:TRUE] forKey:@"Pratik"];
[dic setObject:[NSNumber numberWithBool:FALSE] forKey:@"Sachin"];
if ([dic[@"Pratik"] boolValue])
{
NSLog(@"Boolean is TRUE for 'Pratik'");
}
else
{
NSLog(@"Boolean is FALSE for 'Pratik'");
}
if ([dic[@"Sachin"] boolValue])
{
NSLog(@"Boolean is TRUE for 'Sachin'");
}
else
{
NSLog(@"Boolean is FALSE for 'Sachin'");
}
The output will be as following:
Boolean is TRUE for 'Pratik'
Boolean is FALSE for 'Sachin'