by pavlov · 12y ago · 0 comments
I suspect the messaging-to-nil behavior is mostly confusing to intermediate programmers who only have experience with Java's passive-aggressive null references.
NSArray *obj = nil;
[obj count]; // return 0
In theory a nil object can hide in your code for a long time if you only use methods that can return 0. NSAssert(array, @"Array can't be nil.");Personally I find that the nil behavior provides a useful base guideline for API design. When defining a method signature in Obj-C, you have to ask yourself if it's clear to the user of the method what happens when the method (inevitably) gets sent to nil. In that way, you have to think about the circumstances of the API's actual use, rather than just the ideal case.
[] brackets
{} braces
( opening parenthesis
) closing parenthesis
() parentheses
(( two opening parentheses
)) two closing parentheses
Way more info at http://en.wikipedia.org/wiki/BracketIf I had my way, I'd call them pointyparens.