Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone ios从nsmutable数组中删除对象并重新索引该数组_Iphone_Ios_Nsmutablearray - Fatal编程技术网

Iphone ios从nsmutable数组中删除对象并重新索引该数组

Iphone ios从nsmutable数组中删除对象并重新索引该数组,iphone,ios,nsmutablearray,Iphone,Ios,Nsmutablearray,从nsmutable数组中删除对象并重新编制数组索引的最佳方法是什么?。我的意思是重新索引,例如: 在20个对象的数组中,我移除了索引为11的对象。我有19个对象,但索引11上的对象是零。我想要的是有19个对象的数组,从0到18。您可以使用 - (void)removeObjectAtIndex:(NSUInteger)index 它将自动重新为数组编制索引,因为“索引之外的所有元素都是通过从其索引中减去1来移动的” 有关详细信息,请参阅。您可以使用 - (void)removeObjectA

从nsmutable数组中删除对象并重新编制数组索引的最佳方法是什么?。我的意思是重新索引,例如:

在20个对象的数组中,我移除了索引为11的对象。我有19个对象,但索引11上的对象是零。我想要的是有19个对象的数组,从0到18。

您可以使用

- (void)removeObjectAtIndex:(NSUInteger)index
它将自动重新为数组编制索引,因为“索引
之外的所有元素都是通过从其索引中减去1来移动的”

有关详细信息,请参阅。

您可以使用

- (void)removeObjectAtIndex:(NSUInteger)index
它将自动重新为数组编制索引,因为“索引
之外的所有元素都是通过从其索引中减去1来移动的”

有关详细信息,请参阅。

NSMutableArray会自动为您“重新编制索引”。使用您想要从数组中删除对象的任何方法。NSMutableArray会自动为您执行“重新索引”。使用任何要从数组中删除对象的方法。