What is the difference between “copy” and “retain”?

后端 未结 9 1931
北恋
北恋 2020-12-13 04:10

What is the difference between copy and retain for NSString?

- (void)setString:(NSString*)newString
{
    string = [ne         


        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 05:09

    retain : It is done on the created object, and it just increase the reference count.

    copy -- It creates a new object and when new object is created retain count will be 1.

    Hope This Help for U...:)

提交回复
热议问题