Reputation: 231
I've got a boolean in a plist as so:
Which when viewed as source looks like:
And its read as:
NSDictionary* configPlist = [[NSBundle mainBundle]pathForResource:@"Config" ofType:@"plist"];
BOOL shouldBeFalse = configPlist[@"WhyIsThisReturningTrue"];
But when the code is read shouldBeFalse is YES.
In the debugger configPlist's value for this is NO:
Why therefore is shouldBeFalse getting set to YES when the code is run?
Upvotes: 0
Views: 426
Reputation: 3018
This is because you refer to the NSNumber
pointer, not the value. It is somewhat similar to doing
NSNumber * b = [NSNumber numberWithBool:NO];
if ( b )
{
NSLog(@"This should fire, b is not nil" );
}
if ( b.boolValue )
{
NSLog(@"This should NOT fire, b's value is NO" );
}
So just change it to e.g. [configPlist[@"WhyIsThisReturningTrue"] boolValue]
Upvotes: 2