ARC的@property定义:强还是保留? [英] @property definitions with ARC: strong or retain?

查看:92
本文介绍了ARC的@property定义:强还是保留?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Xcode 4.2和ARC,我注意到NSManagedObject的自动生成的代码对于属性仍然读取如下:

Using Xcode 4.2 and ARC, I notice that the auto-generated code for an NSManagedObject still reads like this for properties:

@property (nonatomic, retain) NSString * someString;

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

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

2)为什么自动生成的代码仍然使用retain

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

3)在此属性声明中正确替换retain的是什么?

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

我目前正在使用NSFetchRequest调试问题,我认为这可能是问题的根源.有什么想法吗?

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

推荐答案

1)现在不应该用强者或弱者代替吗?

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

不.您不能用弱代替保留;他们是不同的.坚强是保留的100%同义词;他们是相同的.您可以使用任何一个,因此这里没有应该".您可以根据需要用strong代替retain,但不必这样做.

No. You cannot replace retain with weak; they are different. And strong is a 100% synonym for retain; they are identical. You can use either, so there is no "should" here. You can replace retain with strong if you like, but you don't have to.

2)为什么自动生成的代码仍然使用保留

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

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

Why not? See (1). retain is correct so there is no problem.

3)此属性声明中保留的正确替代方法是什么?

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

无需替换保留.

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

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

不是.

这篇关于ARC的@property定义:强还是保留?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆