Does NSArray initWithObjects: retain objects?

前端 未结 2 1903
生来不讨喜
生来不讨喜 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:16

    initWithObjects retains all items in the array.

    initWithObjects: count:

    • (id) initWithObjects: (id*)objects count: (NSUInteger)count; Availability: OpenStep

    This is a designated initialiser for the class. Subclasses must override this method. This should initialize the array with count (may be zero) objects. Retains each object placed in the array. Calls -init (which does nothing but maintain MacOS-X compatibility), and needs to be re-implemented in subclasses in order to have all other initialisers work.

提交回复
热议问题