1 null xcode cocoa objective-c
我很好奇为什么一个变量明显分配给nil,用NSLog打印为(null):
NSString *myVar = nil;
NSLog(@"%@", myVar);
# RESULT: ' (null) '
Run Code Online (Sandbox Code Playgroud)
考虑到在Objective-C中弄清楚所有不同类型的"虚无",并且让我尝试测试各种IF NULL语法,这当然是相当混乱的.
总结出不同种类的"虚无":
nil //Null pointer to an Objective-C object
Nil //Null pointer to an Objective-C class
NULL //Null pointer
Run Code Online (Sandbox Code Playgroud)
以上所有都定义为((void *)0).
| 归档时间: |
|
| 查看次数: |
2857 次 |
| 最近记录: |