Possible Duplicate:
Sending a message to nil?
If a reference to NSMutableArray
is not pointing to any object at all, because none was instantiated, why can the instance method still be invoked without any run-time error?
NSMutableArray *foo = nil;
NSLog(@"[null count] is %i", [foo count]);
NSLog(@"[null count] again is %i", [(NSMutableArray *) nil count]);
The above lines both print out 0
instead of causing a bad memory access or causing an error that says there is no instance.