Monday, May 25, 2009

iPhone dev Stupidity 11

* Sending message to nil.

In Objective-C it's safe to send message to nil - no runtime error, just some default behavior. 

   NSIndexPath * path = [table indexPathForSelectedRow];


   NSLog(@"path ref: %d, path %@", [path retainCount], path);


When path is nil, [path retainCount] will return 0 instead of triggering an error.


No comments: