xcode 'weak' 属性的 @synthesize 只允许在 ARC 或 GC 模式下首次编译 Urbanship
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18936209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
@synthesize of 'weak' property is only allowed in ARC or GC mode with first compile of urbanship
提问by Kmb40
Basically, I have an IOS app that functioned without issue.
基本上,我有一个可以正常运行的 IOS 应用程序。
While following the instructions at http://docs.urbanairship.com/build/ios.html#ios-push-getting-started, I reached the "Register Your Device" section asking me to compile.
按照http://docs.urbanairship.com/build/ios.html#ios-push-getting-started 上的说明进行操作时,我到达了“注册您的设备”部分,要求我进行编译。
After attempting to build the code in xCode 5 I received the following error "@implementation UAPushSettingsAddTagViewController @synthesize of 'weak' property is only allowed in ARC or GC mode".
尝试在 xCode 5 中构建代码后,我收到以下错误“@implementation UAPushSettingsAddTagViewController @synthesize of 'weak' property is only allowed in ARC or GC mode”。
Note:ARC mode is not in use.
注意:ARC 模式未使用。
回答by Duncan C
Search for "weak" in your project code and the libraries you include. Change it to a "assign"
在您的项目代码和您包含的库中搜索“弱”。将其更改为“分配”
Edit:
编辑:
As @TaylorHalliday points out in his comment below, my answer was rather incomplete.
正如@TaylorHalliday 在下面的评论中指出的那样,我的回答相当不完整。
Changing weak properties to assign will get rid of compiler errors, but it will potentially cause memory management problems if you don't understand how to use manual reference counting.
更改要分配的弱属性将消除编译器错误,但如果您不了解如何使用手动引用计数,则可能会导致内存管理问题。
Since you're using manual reference counting you will need to go through your code and make sure that you retain objects that you need to persist, and then release all owning references to objects when you are done with them. Explaining the details is beyond the scope of a forum post. I suggest you search on "About Memory Management" in the Xcode help system, and read the entire Advanced Memory Management Guide.
由于您使用的是手动引用计数,因此您需要仔细检查代码并确保保留需要持久化的对象,然后在完成后释放对对象的所有拥有引用。解释细节超出了论坛帖子的范围。我建议您在 Xcode 帮助系统中搜索“关于内存管理”,并阅读整个高级内存管理指南。
You should probably also run the Analyze tool on your project to look for possible memory management problems.
您可能还应该对您的项目运行分析工具以查找可能的内存管理问题。
Better yet, convert your project to use ARC. It's much easier to avoid memory management problems when using ARC.
更好的是,将您的项目转换为使用 ARC。使用 ARC 时避免内存管理问题要容易得多。
回答by zeeawan
I got same error when I added these two filesto my project. My project wasn't enabled for ARC. I had to remove these files first and then had to convert my project to ARC. Then adding these files caused no error.
当我将这两个文件添加到我的项目时,我遇到了同样的错误。我的项目没有启用 ARC。我必须先删除这些文件,然后才必须将我的项目转换为 ARC。然后添加这些文件不会导致错误。