I got a boolean value from a json object using dictionary. at console, I can see 0 or 1. But my comparision always return true.
BOOL *result =[dictionary valueForKey:@"result"];
if (result == YES) {
[parser release];
}
else {
errorLbl.text = @"Login failed";
}
have you tried adding a boolValue at the end of [dictionary valueForKey:@"result"]boolValue];
You need to convert the value from the dictionary. You can't translate it directly to a BOOL * (BOOL pointer).
Suppose you get a NSString* from your dictionary, you can do:
NSString *result = [dictionary valueForKey:@"result"];
if ([result boolValue]) {
[parser release];
} else {
errorLbl.text = @"Login failed";
}
Assuming you can use boolValue message with your protocol.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With