mea*_*lai -1 iphone pointers if-statement ios
我有一个应用程序提交到Apple Store,它通过了.但我发现有一个错误会让应用程序崩溃.最后,我发现真正的问题是代码的快照有相反的结果.
码:
CGPoint now;
CGPoint old;
UIView *lastDot;
now = dotView.center;
if(lastDot){
//release version, will go here. then crashed.
old = lastDot.center;
}else{
//debug version, will go here. run ok.
}
Run Code Online (Sandbox Code Playgroud)
我声明了一个UIView指针,并用"if语句"检查它,
UIView*lastDot;
调试版本将lastDot视为nil,但发布版本认为不是null.
任何人都可以给我任何想法?谢谢.
根据您的编译器设置,调试版本通常会初始化指向某些标记值的指针0xcccccccc.
UIView *lastDot = nil;
Run Code Online (Sandbox Code Playgroud)
应该按预期工作.
| 归档时间: |
|
| 查看次数: |
111 次 |
| 最近记录: |