【发布时间】:2020-04-15 13:15:35
【问题描述】:
我尝试过使用
NSMutableArray *existingArray = [@[@"1", @"3", @"4"] mutableCopy];
NSArray *newItems = @[@"2", @"2", @"2", @"2"];
[existingArray insertObjects:newItems atIndexes:[NSIndexSet indexSetWithIndex:1]];
上面的代码最终会崩溃,因为我想为所有新项目提供所有索引。
我想要的是能够在 existingArray 的位置 1 插入 newItems,同时保留最终数组中 newItems 的顺序。
有没有简单的方法来提供所有这些索引?
【问题讨论】:
标签: ios arrays objective-c