33 iphone xcode automatic-ref-counting
我想知道我的Xcode iPhone项目是否正在使用ARC,我不记得在创建项目时是否勾选了该框.
我怎样才能获得这些信息?
Ste*_*her 52
选择您的项目,然后选择Build Settings.在Apple LLVM编译器 - 语言部分中查找Objective-C自动引用计数.确保选择目标; 虽然您可以在项目中设置它,但目标可以覆盖它.
(您也可以使用"构建设置"中的搜索栏OBJC_ARC
.)
请记住,您可以在构建阶段基于每个文件打开或关闭ARC.
或者,只需在代码中尝试这样的事情:
[[[NSObject alloc] init] autorelease]
Run Code Online (Sandbox Code Playgroud)
如果您收到错误:
ARC forbids explicit message send of 'autorelease'
Run Code Online (Sandbox Code Playgroud)
然后你正在使用ARC.
您还可以通过检查来源源代码文件中的ARC:
#if !__has_feature(objc_arc)
#error This file must be built with ARC.
// You can turn on ARC for only this file by adding -fobjc-arc to the build phase.
#endif
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9560 次 |
最近记录: |