NSMutable Array 难度 [英] NSMutable Array difficulty
问题描述
这里是 iOS 开发新手.我的阵列有问题.我正在用 iCarousel 制作一个应用程序.每当它停止到一个视图时,它将删除当前视图或索引,如下所示:
Beginner iOS dev here. I have a problem in my array. Im making an app with iCarousel. That whenever it stop to a view it will delete the current view or index, like this:
NSInteger index = carousel.currentItemIndex;
[carousel removeItemAtIndex:index animated:YES];
[images removeObjectAtIndex:index];
所以我的数组有一个索引:
So my array have an index with this:
0 1 2 3 4 5
0 1 2 3 4 5
当我使用上面的方法(例如它落在视图 3 上)时,它会变成这样:
when I use the method above ( for example it lands on view 3) it become like this:
0 1 2 4 5
即使我删除,如何保持相同的数组索引/值?还是我应该更新它?
How to remain the same array index/value even if I delete? or should I update it?
我尝试使用 [carousel reloadData];
但仍然没有效果.
I tried using [carousel reloadData];
but still no effect.
推荐答案
Use [carousel replaceItemAtIndex:index withObject:[NSNull null]];
并检查对象是否属于 NSNull
类型然后什么都不做或根据您的要求.
Use [carousel replaceItemAtIndex:index withObject:[NSNull null]];
and check if the object is of type NSNull
then do nothing or according to your requirement.
这篇关于NSMutable Array 难度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!