NSMutableArray的最后一个对象

问题描述:

我想的iCarousel,有一个删除视图的索引和数组的索引我删除它的功能,NSMutableArray的最后一个对象

NSInteger index = carousel.currentItemIndex; 
[carousel removeItemAtIndex:index animated:YES]; 
[imagesArray removeObjectAtIndex:index]; 

直到一个项目仍然存在,那么如果一个项目仍然是我想要插入它的重复。我试过这个:

insertItemAtindex:carousel.currentItemIndex但它插入最后一个视图。

但我想要的是在我的视图中插入carousel's/imagesArray最后一个对象/索引。我该如何实现它,或者如何确定视图中剩下的NSMutableArray的最后一个对象?

可以使用检查最后一个对象 -

int count = [yourArray count]; 
[yourArray objectAtIndex:count - 1]; //this will always return you last object 
+0

你能解释一下这个吗? – Bazinga

+1

只要这样做:'lastObject = [yourArray objectAtIndex:([yourArray count] -1)]' – pasawaya

+0

@qegal - 同样的事情:) – rishi

carousel.lastObject !!!!!!!!!!