In an Apple example I've seen this:
myController *controller = [viewControllers objectAtIndex:page];
if ((NSNull *)controller == [NSNull null]) {
controller = [[myController alloc] initWithPageNumber:page];
[viewControllers replaceObjectAtIndex:page withObject:controller];
[controller release];
}
I am very interested in this line:
if ((NSNull *)controller == [NSNull null]) {
If I would have done that, I would have just checked for nil. Why do they do that so damn complicated? And what's that actually doing? For me it looks like they're casting the controller object to NSNull, and then check if that's the same as null from NSNull.
A.F.A.I.K. nil means "no object", and null means "nothing". Please help me to get a clear picture here!