Nsmutablearray 在索引处插入对象但向下移动已插入的对象
我想问以下情况是否有可能发生。 我有一个 Nsmutablearray,里面有 5 个对象。我将 Nsmutablearray 加载到 uitableview 上。我想在其他五个对象的顶部插入一个新对象,但也将所有先前插入的对象向下移动一个。让我给你一个例子,
0 one
1 two
2 three
3 four
4 five
我想在将新对象插入顶部后得到这样的结果
0 six
1 one
2 two
3 three
4 four
5 five
任何帮助表示赞赏。
I wanted to ask if the following scenario is somehow possible to happen.
I have an Nsmutablearray and i have in it 5 objects. I load the Nsmutablearray on an uitableview. I want to insert a new object at the top of the other five objects but also move down all the previously inserted objects down by one. let me give you an example
0 one
1 two
2 three
3 four
4 five
i want to result like this after the new object inserted on the top
0 six
1 one
2 two
3 three
4 four
5 five
Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NSMutableArray
的这个方法就是您正在寻找的。This method of
NSMutableArray
is what you are looking for.您正在寻找的方法是:
- [NSMutableArray insertObject:atIndex:]
。在您的示例中,索引将为 0。
The method you are looking for is:
- [NSMutableArray insertObject:atIndex:]
.In your example, the index would be 0.