Reputation: 327
I'm new to ios. I want to check if statement is true, but this condition gives true everytime even when it's false.
NSMutableArray *passengers=loginObj.passengers;
PassengerObj *passenger=[passengers objectAtIndex:0];
if([[passenger checkedIn] objectAtIndex:0])
{
[somestatement];
}
in debugger
_checkedIn __NSCFArray * @"1 object" 0x168b8200
>[0] __NSCFBoolean * @"0" 0x37e696d4
Upvotes: 1
Views: 51
Reputation: 4465
Assuming your array only contains strings that contain a 1 or a 0, you can compare the string:
if ([[[passenger checkedIn] objectAtIndex:0] isEqualToString:@"0"])
Of course it would be more readable to have an array of NSNumber
s and use
if ([[[passenger checkedIn] objectAtIndex:0] boolValue])
Upvotes: 4