objective-c - ARC : strong or retain? 的@property 定义

标签 objective-c properties automatic-ref-counting nsmanagedobject retain

使用 Xcode 4.2 和 ARC,我注意到自动生成的 NSManagedObject 代码对于属性仍然是这样的:

@property (nonatomic, retain) NSString * someString;

1) 现在不应该将 retain 替换为 strongweak 吗?

2) 为什么自动生成的代码还是使用retain

3) 在此属性语句中,retain 的正确替换是什么?

我目前正在使用 NSFetchRequest 调试一个问题,我认为这可能是问题的根源。想法?

最佳答案

1) Shouldn't retain now be replace with strong or weak?

没有。你不能用弱替换保留;它们不一样。而strong是100%保留的同义词;它们是相同的。你可以使用任何一个,所以这里没有“应该”。如果你愿意,你可以用 strong 替换 retain,但你不是必须的。

2) Why does the auto-generated code still use retain

为什么不呢?见(1)。保留是正确的,所以没有问题。

3) What is the correct replacement for retain in this property statement?

不需要替换retain。

I'm currently debugging a problem using NSFetchRequest, and I thought this might be the source of the problem. Thoughts?

不是。

关于objective-c - ARC : strong or retain? 的@property 定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7796476/

相关文章:

iphone - SFHFKeychainUtils。 iOS 钥匙串(keychain)。弧兼容

ios - ARC 如何在循环中工作?

swift - 为什么我从将弱 self 传递到静态函数的闭包中得到一个保留周期?

ios - 滚动 UIImageView 图像

c++ - 在 C++ 中使用 Objective-C 类

ios - MKPointAnnotation 标签

C# : assign data to properties via constructor vs. 实例化

properties - Gradle/Groovy 属性

objective-c - App Store Updater 是否始终下载所有内容?

c# - 如何为用户控件属性设置初始值?