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 *a
This is the correct behavior. Try inspecting the actual class for that object:
NSArray *array = [[NSArray alloc] init];
NSLog(@"%@", NSStringFromClass([array class]));
The output you get is something like:
2013-02-15 23:42:31.272 Project[91998:c07] __NSArrayI
So the actual class is __NSArrayI
(a private subclass of NSArray
), not NSArray
itself. Typically, isKindOfClass:
provides more useful results.