使用 Xcode 4.2 和 ARC,我注意到自动生成的 NSManagedObject
代码对于属性仍然是这样的:
@property (nonatomic, retain) NSString * someString;
1) 现在不应该将 retain
替换为 strong
或 weak
吗?
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/