received data from JSON, which is looks like:
{
myself = 1;
"id" = 123;
}
and I put it into a NSDictionary *messageDic, I also defined a value *isMyself to receive the value of myself
Boolean isMyself = [messageDic objectForKey:@"myself"];
but it does not work.
So I print the date type,
const char* className = class_getName([[messageDic objectForKey:@"myself"] class]);
NSLog(@"yourObject is a: %s", className);
NSLog(@"Size of BOOL %d", sizeof(isMyself));
NSLog(@"Size of BOOL %@", [messageDic objectForKey:@"myself"]);
the results are:
2012-08-01 17:41:48.886 yourObject is a: __NSCFBoolean
2012-08-01 17:41:48.887 Size of BOOL 1
2012-08-01 17:41:48.887 Size of BOOL 0
and the if section below also does not work.
if ([messageDic objectForKey:@"myself"] == 0)
I tried
NSCFBoolean *isMyself = [messageDic objectForKey:@"myself"];
I got error form above.
my question is what should I do to test the value of [messageDic objectForKey:@"myself"]? and what is the __NSCFBoolean?
Thanks!
the result you’ve got from [messageDic objectForKey:@”myself”], which is a NSNumber, then you need to convert the result to Bool. So try below: