16
什么时候在Objective-C中使用nil和NULL?
这是示例代码: NSDictionary *myDictionary = [NSDictionary dictionary]; NSNumber *myNumber = [myDictionary valueForKey: @"MyNumber"]; NSLog(@"myNumber = %@", myNumber); // output myNumber = (null) if (myNumber == nil) NSLog(@"test 1 myNumber == nil"); if (myNumber == NULL) NSLog(@"test 2 myNumber == NULL"); if ([myNumber isEqual:[NSNull null]]) NSLog(@"test 3 myNumber == [NSNull null]"); 什么时候应该使用nil,NULL和[NSNull …
170
objective-c
null
nsnull