Does NSArray initWithObjects: retain objects?

前端 未结 2 1902
生来不讨喜
生来不讨喜 2021-01-21 04:42

When adding objects to an NSArray using \"initWithObjects\" can anyone confirm for me that the items are retained. I am pretty sure they are, but can\'t find it mentioned anywhe

2条回答
  •  野的像风
    2021-01-21 05:24

    Objects are expected to take ownership of the things they need to keep around. An array is responsible for its items, therefore it retains them. See the memory management guide for complete details. (No, seriously, read it. You'll thank yourself later when you don't have to ask this question about every class you use and your program isn't crashing every five seconds.)

提交回复
热议问题