2011-02-10 56 views
0
myCustomController *controller = [myMutableArray objectAtIndex:page]; 

NSLog(@"%@",controller); // <- THIS RETURNS NULL IN CONSOLE 

if ((NSNull *)controller == [NSNull null]) { 
// Why is the above check not working if controller in console says it's null? 
// It's not jumping into this loop. Has something changed in iOS4.0 SDK? 
} 

這是什麼問題null檢查viewController,它似乎並沒有工作。對於ViewController的這個NULL檢查有什麼問題?

回答

4

NSLog應該在控制檯返回(null)(這可能是nil描述),不NULL。您的支票應該看起來像這樣:

if (!controller) { 
    // do some stuff here 
} 
+2

或者,您可以'if(controller == nil)`(兩者同樣正確)。 – 2011-02-10 05:08:12