开发者

What is wrong with this NULL check for a ViewController?

开发者 https://www.devze.com 2023-02-09 09:51 出处:网络
myCustomController *controller = [myMutableArray objectAtIndex:page]; NSLog(@\"%@\",controller); // <- THIS RETURNS NULL IN CONSOLE
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?
}

what is wrong with this null check for a viewController, it does not seem to be working.


NSLog should return (null) (which probably is description for nil), not NULL in console. Your check should look like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号