objective-c - iOS:将对象添加到NSMutableArray的特定位置

标签 objective-c xcode ios nsmutablearray

在我的项目中,我想在NSMutableArray的特定位置添加一个对象,例如:

if(index ==1) {
// I want add object at position 1 of NSMutableArray
}

if(index == 2) {
// I want add object at position 2 of NSMutableArray
}
...
if(index == 15) {
// I want add object at position 15 of NSMutableArray
}

我能怎么做?

最佳答案

使用[array insertObject:object atIndex:index];

关于objective-c - iOS:将对象添加到NSMutableArray的特定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5754225/

相关文章:

iOS - Google Analytics 委托(delegate)方法未被调用且页面 View 未跟踪

ios - 如何使用 AVAssetWriter 编写自定义 udta 原子?

iphone - 尝试在 ios 中使用 TableView ,出现错误

objective-c - 使用 MapKit 和 UIGestureRecognizer 在触摸时添加注释图钉

ios - NSDateFormatter为什么不解析此日期?

ios - 在上传到 Github 时,为了安全起见,我应该从 Xcode 项目中删除任何内容吗?

ios - Xcode 中的 AudioPlayer 快进

iOS - bodyWithPolygonFromPath : Body is the same as the path but collisions are not working properly

ios - 使用 swipegester 自定义页面浏览指示器和 uipageviewcontroller

iphone - 无法在 Instruments : At least one target failed to launch 中启动我的应用程序