Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

objective c - @property definitions with ARC: strong or retain?

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) Shouldn't retain now be replace with strong or weak?

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

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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) Why does the auto-generated code still use retain

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

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

There is no need to replace retain.

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

It isn't.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...