In the code below I thought the second condition would be true, but it is turning out as false. Am I missing something? Please help me understand.
NSArray *array = [[NSArray alloc] init];
NSLog(@"%@", NSStringFromClass([array class]));
if ([array isMemberOfClass:[NSObject class]]) {
NSLog(@"Member NSObject"); //Didn't print;
}
if ([array isMemberOfClass:[NSArray class]]) {
NSLog(@"Member NSArray"); //Didn't print; I don't understand why?
}
if ([array isKindOfClass:[NSObject class]]) {
NSLog(@"Kind of NSObject"); //Printed; Expected
}
if ([array isKindOfClass:[NSArray class]]) {
NSLog(@"Kind of NSArray"); //Printed; Expected
}
Edit
I created sub class of NSArray as MyArray and tested its instance using isMemberOfClass as below
if ([myArray isMemberOfClass:[MyArray class]]) {
NSLog(@"Member MyArray"); //Printed;
}
So, I guess isMemberOfClass not possible on NSArray, probably on some other framework classes as well.
Thanks.