`[blah addObject:@"1"];` 和 `[blah insertObject:@"0"]; 之间有什么区别? atIndex:0];`?
之间有什么区别
[blah addObject:@"1"];
: 和和
[blah insertObject:@"0" atIndex:0];
???
?我知道它们都是 NSMutableArray 的。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
addObject
最后添加一个对象。insertObject:atIndex
在指定索引处添加一个对象。该指定索引后面的所有对象都会右移一位。例如,假设您有一个包含以下对象的数组:
并且您使用
addObject
添加 E。然后它看起来像:然后你在索引 2 处插入 F。然后它看起来像:
addObject
adds an object at last.insertObject:atIndex
adds an object at specified index. All objects further to that specified index are shifted one position right.For example, say you have an array with following objects:
And you add E using
addObject
. Then it will look like:Then you insert F at index 2. Then it will look like: