Re:nil, Nil, NULL, NSNull
by scrumper on Monday January 07, 2013 @01:38PM
(#5022406)
Any use cases for Nil, that is, the class pointer to nothing? I've not seen it in the wild (which isn't saying a great deal.)
[ Parent
| on HN ]
You could use it to test whether or not you really got a class from NSClassFromString(). For instance:
Class _myClass;
// aClassName was previously defined
if((_myClass = NSClassFromString(aClassName)) == Nil)
[NSException raise:@"InvalidClass"
reason:@"Unknown class named %@.", aClassName);
id myObj = [[_myClass alloc] init];
[myObj whatever];