Gruntfluffle
Gruntfluffle

Reputation: 231

Boolean value set to false in plist is coming out as true

I've got a boolean in a plist as so:

enter image description here

Which when viewed as source looks like:

enter image description here

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:enter image description here

Why therefore is shouldBeFalse getting set to YES when the code is run?

Upvotes: 0

Views: 426

Answers (1)

skaak
skaak

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

Related Questions