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

查看:30
本文介绍了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% 同义词;它们是相同的.你可以使用任何一个,所以这里没有应该".如果您愿意,可以将保留替换为强,但您不必这样做.

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) 为什么自动生成的代码仍然使用retain

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

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

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

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

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

不需要替换retain.

There is no need to replace retain.

我目前正在使用 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天全站免登陆