5 ms·
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.)
by scrumper 14y ago
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.)
- mmariani 14y agoYou 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];
- scrumper 14y agoMakes sense, thanks.