NSString property: copy or retain?

前端 未结 10 984
予麋鹿
予麋鹿 2020-11-22 02:53

Let\'s say I have a class called SomeClass with a string property name:

@interface SomeClass : NSObject
{
    NSString* name;
}

@p         


        
10条回答
  •  广开言路
    2020-11-22 03:04

    Copy should be used for NSString. If it's Mutable, then it gets copied. If it's not, then it just gets retained. Exactly the semantics that you want in an app (let the type do what's best).

提交回复
热议问题