Objective C - Assign, Copy, Retain

后端 未结 4 1386
时光取名叫无心
时光取名叫无心 2020-11-28 01:14

I\'m new to Objective C. I have basic knowledge in C, including the concept of pointers. I have two basic questions:

  1. Can someone explain the difference between
4条回答
  •  天涯浪人
    2020-11-28 01:51

    The Memory Management Programming Guide from the iOS Reference Library has basics of assign, copy, and retain with analogies and examples.

    copy Makes a copy of an object, and returns it with retain count of 1. If you copy an object, you own the copy. This applies to any method that contains the word copy where “copy” refers to the object being returned.

    retain Increases the retain count of an object by 1. Takes ownership of an object.

    release Decreases the retain count of an object by 1. Relinquishes ownership of an object.

提交回复
热议问题