Question about factory method object lifetimes in Objective-C/Cocoa (to retain or not…)

前端 未结 4 1093
遇见更好的自我
遇见更好的自我 2021-01-03 11:38

From reading the memory management docs in the SDK, I gathered that factory methods (static constructor methods) would typically be retaining the object for me and adding it

4条回答
  •  粉色の甜心
    2021-01-03 11:49

    As soon as you add your object to the array, there is an implicit call to retain for this object, which means once added to the array you can release it from the source, and when you'll call the remove method from the array there will also be an implicit call to release.

提交回复
热议问题