ViewController的NULL检查有什么问题?

时间:2011-02-10 04:59:23

标签: objective-c iphone cocoa-touch ios4 null

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检查有什么问题,它似乎无法正常工作。

1 个答案:

答案 0 :(得分:4)

NSLog应该在控制台中返回(null)(可能是nil的说明),而不是NULL。您的支票应如下所示:

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