copy NSArray inside an empty NSArray

后端 未结 2 932
执念已碎
执念已碎 2021-01-16 18:45

I have a first NSArray firstArray and I do

[firstArray removeAllObjects];

after I want fill it with the content of an other a

2条回答
  •  没有蜡笔的小新
    2021-01-16 18:53

    No, firstArray = secondArray will reassign the pointers, this is not the behavior you want. You want [firstArray addObjectsFromArray:secondArray]

提交回复
热议问题