初学者的iOS dev的这里。 我在我的阵列中的问题。 林制造与iCarousel的应用程序。 每当它停到一个视图,将删除当前视图或索引,就像这样:
NSInteger index = carousel.currentItemIndex;
[carousel removeItemAtIndex:index animated:YES];
[images removeObjectAtIndex:index];
因此,我的阵列有这个索引:
0 1 2 3 4 5
当我使用上面的方法(例如它的土地上视图3)它成为这样的:
0 1 2 4 5
如何保持,即使我删除同一数组索引/值? 或者我应该更新?
我尝试使用[carousel reloadData];
但仍然没有效果。
使用[carousel replaceItemAtIndex:index withObject:[NSNull null]];
和检查对象的类型的NSNull
然后什么都不做或根据您的要求。
1)你必须在实施@synthesize电话。 码:
@synthesize myNSMutableArray;
2)用 “自我”。 以使用由参数产生的设定器/吸气剂。 码:
self.myNSMutableArray = [[NSMutableArray alloc] initWithObjects:@"object1.png", @"object2.png", @"object3.png", nil];
[self.myNSMutableArray replaceObjectAtIndex:0 withObject: @"newObject.png"];
Without the "self." you are changing the iVar directly.