isMemberOfClass problem
I'm trying to log if an object in my mutable array is a member of the class NSString
. Here is my code:
id obj = [mutArr objectAtIndex:1];
BOOL classMem = [obj isMemberOfClass:[NSString class]];
NSLog(@"%@", classMem);
Instead of printing YES
or NO
, I get the output (null)
. Can you please tell me why this i开发者_C百科s the case?
Thank you!!
BOOL
is not an object, so shouldn't be logged with %@
. Log it with the format string %d
instead. Or, if you want more legible output, you can use:
NSLog(@"%@", classMem ? @"YES" : @"NO");
精彩评论