NSArray property: copy or retain?

后端 未结 4 1563
醉话见心
醉话见心 2021-02-04 02:04

According to this: NSString property: copy or retain?

For NSString/NSMutableString, copy is recommended.

How about NSArray/NSMutableArray?

4条回答
  •  情话喂你
    2021-02-04 02:34

    If it is a problem when the underlying data changes, use copy. In fact, this is what you want most of the time, as changing data behind someone's back is a good source for bugs.

    Note that copy will essentially just be a retain for an NSArray. Only when you throw an NSMutableArray in, there is more work involved.

提交回复
热议问题