本文介绍了应用程序转换为ARC,现在收到有关我的属性的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚将我的应用转换为 ARC ,虽然它构建良好,但我得到600条警告,所有这些都与我的属性有关。例如:

I just converted my app to ARC, and while it builds fine, I get like 600 warnings, all pertaining to my properties. Such as:

未指定'assign','retain'或'copy'属性 - 'assign'为
假设

No 'assign', 'retain' or 'copy' attribute is specified - 'assign' is assumed

在Xcode转换我的代码后,这是我的属性:

After Xcode converted my code, here is what my properties look like:

@property (nonatomic) EKEventStore *eventStore;
@property (nonatomic) EKCalendar *defaultCalendar;
@property (nonatomic) UIActionSheet *currentActionSheet;
@property (nonatomic) UILabel *noEventLabel;

有人谈到需要添加 strong 来所有这些。是这样的吗? Xcode是否忘记添加内容?

Someone talked about needing to add strong to all of these. Is this the case? Did Xcode forget to add something?

推荐答案

ARC是对的。你不能拥有没有内存管理资格;你必须说分配,保留(或强大,这是相同的东西),或弱。

ARC is right. You cannot have no memory-management qualifer; you must say assign, retain (or strong which is the same thing), or weak.

以前,assign是默认值。但这可能不是你想要的,因为它是最糟糕的选择 - 它是一种旧式的非ARC弱引用。您要么需要智能ARC弱引用(当对象不存在时为nil)或强引用(由ARC为您管理内存)。

Previously, assign was the default. But that is probably not what you want, because is it is the worst possible option - it is an old-style non-ARC weak reference. You either want a smart ARC weak reference (goes to nil when the object goes out of existence) or a strong reference (memory-managed for you by ARC).

这篇关于应用程序转换为ARC,现在收到有关我的属性的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 10:08