Differences between [NSArray arrayWithArray:] and [NSArray copy]

前端 未结 7 2046
清歌不尽
清歌不尽 2021-02-12 13:50

lately I work much with arrays and I\'m wonder.. what\'s diffrences between those two lines.

NSArray *array = [NSArray arrayWithArray:someArray];
7条回答
  •  梦谈多话
    2021-02-12 14:11

    In addition to the other answers, also note, that when someArray is nil, the first line will make array point to an empty array and the second will make it point to nil. This might be an important difference, especially in mutable arrays.

提交回复
热议问题