Objective c ViewController的此空检查有什么问题? myCustomController*controller=[myMutableArray objectAtIndex:page]; NSLog(@“%@”,控制器);//

Objective c ViewController的此空检查有什么问题? myCustomController*controller=[myMutableArray objectAtIndex:page]; NSLog(@“%@”,控制器);//,objective-c,iphone,cocoa-touch,ios4,null,Objective C,Iphone,Cocoa Touch,Ios4,Null,NSLog应该返回(null)(这可能是nil的描述),而不是控制台中的null。您的支票应如下所示: myCustomController *controller = [myMutableArray objectAtIndex:page]; NSLog(@"%@",controller); // <- THIS RETURNS NULL IN CONSOLE if ((NSNull *)controller == [NSNull null]) { // Why is the abo

NSLog
应该返回
(null)
(这可能是
nil
的描述),而不是控制台中的
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?
}

NSLog
应该返回
(null)
(这可能是
nil
的描述),而不是控制台中的
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?
}

或者,如果(controller==nil),则可以执行
(两者都是同样正确的)。不能在数组中存储零。这就是NSNull类的用途。另一方面,如果
myMutableArray
本身为nil,则可以从中获取nil。或者,如果(controller==nil)
(两者都同样正确),则可以执行
if(controller==nil)
(两者都同样正确)。但您永远不应该从数组中获取nil。不能在数组中存储零。这就是NSNull类的用途。另一方面,如果
myMutableArray
本身为nil,则可能会得到nil。