Iphone NSMutableArray索引困难
删除Iphone NSMutableArray索引困难,iphone,ios,xcode,Iphone,Ios,Xcode,删除iCarousel视图时,如下所示: [carousel removietematindex:index动画:是] 如何维护/保留已删除的视图/索引,即使是转到不同的viewController?。 因为根据我对它的经验,它会返回它的观点, 或者将删除的索引放入数组中?这可能吗 已经尝试将数组添加到应用程序委托,但仍然没有成功。 还没有尝试过singleton。但是还有其他方法吗,谢谢您的帮助。是的,您可以在AppDelegate中创建一个数组并将索引放入该数组。但在此之前,您应该通过以下
iCarousel
视图时,如下所示:
[carousel removietematindex:index动画:是]代码>
如何维护/保留已删除的视图/索引,即使是转到不同的viewController
?。
因为根据我对它的经验,它会返回它的观点,
或者将删除的索引放入数组中?这可能吗
已经尝试将数组添加到应用程序委托
,但仍然没有成功。
还没有尝试过singleton
。但是还有其他方法吗,谢谢您的帮助。是的,您可以在AppDelegate中创建一个数组并将索引放入该数组。但在此之前,您应该通过以下方式从NSInteger(int)创建NSNumber对象:
// This line should be in your delegate
NSMutableArray *indexesArray = [[NSMutableArray alloc] init];
// In your controller:
NSInteger index = 1; // Use your index instead
NSNumber *indexObject = [NSNumber numberWithInt:index];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.indexesArray addObject:indexObject];
视图也是如此。您还可以将UIView对象存储在NSMutableArray中
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[appDelegate.viewsArray addObject:view];
在删除之前,请将这些索引保存到数组中。我想要的是,即使在删除某个索引时,即使转到另一个视图,该索引也将保留?