__NSCFBoolean isEqualToString:]: unrecognized selector sent to instance

json, objective-c

Solution

`value` is a NSNumber object (__NSCFBoolean, because NSNumber is a class cluster) and not a string! Use `[value boolValue]` to determine whether it's 0 or 1.

Casting an object doesn't change it's type!

Problem

when i am getting values from `JSON` php then i am getting issue for `__NSCFBoolean isEqualToString`: My code is as follow: ``` - (void)connectionDidFinishLoading:(NSURLConnection *)connection { //convert to JSON for(id key in res) { id value = [res objectForKey:key]; NSString *keyAsString = (NSString *)key; NSString *valueAsString = (NSString *)value; //NSCFBoolean /*if([value isKindOfClass:[NSNumber class]]) { printf("Number"); } else if([value isKindOfClass:[NSString class]]) { printf("String --- \n"); if([value isEqualToString:@"0"]) { printf("Wrong \n"); } else { printf("Right \n"); } }*/ NSLog(@"%@",[valueAsString class]); if([keyAsString isEqualToString:@"success"]) { printf("Working \n"); } else { printf("Not Working\n"); } //Error is in below line if([valueAsString isEqualToString:@"0"])// strcmp([value objCType], @encode(BOOL)) == 1) { [self loginSuccess]; } else if(strcmp([value objCType], @encode(BOOL)) == 0) { [self loginFailure]; } NSLog(@"key: %@", keyAsString); NSLog(@"value: %@", valueAsString); } ``` } } Getting issue of `[__NSCFBoolean isEqualToString:]:` unrecognized selector sent to instance 0x1dc9964 Searching Google for this issue from yesterday, But No solution yet. NSCFBoolean is also not available in iOS 6.0, now. So what could i do to check "0" or "1" from `JSON` string? Please help.

Original source