You can't store BOOL
objects in a dictionary (or other collections) without first wrapping it in an NSNumber
. This means that when you get the value from the dictionary, you are getting the NSNumber
. You need to convert this to BOOL
.
You can do:
// Assuming usepasive is defined as BOOL
usepassive = [[agencydata objectForKey:@"passive"] boolValue];
NSLog(@"agencydata usepassive: %@", [agencydata objectForKey:@"passive"]); // logs the NSNumber
NSLog(@"vardata usepassive: %hhd", usepassive); // logs the BOOL
Also consider modern syntax:
usepassive = [agencydata[@"passive"] boolValue];
NSLog(@"agencydata usepassive: %@", agencydata[@"passive"]); // logs the NSNumber
NSLog(@"vardata usepassive: %hhd", usepassive); // logs the BOOL