我正在尝试将图像保存在 NSMutable 数组中,但它不工作
这就是我正在做的
[imagesList addObject:[UIImage imageNamed:@"b.png"]];
执行此行后,我注意到对象的数量仍然为 0 有什么原因吗?
谢谢
我在几个方面重复了这段代码:
在全球范围内,我声明:
NSMutableArray *imagesList;
NSUserDefaults *imagesHistory;
在我的 viewdidload 方法中,我写道:
imagesHistory=[NSUserDefaults standardUserDefaults]; //imagesHistory is created globallt as NSUserDefault imagesHistory
[imagesHistory setObject:imagesList forKey:@"images history"];
UIImage *image;
image=[UIImage imageNamed:@"b.png"];
[imagesList addObject:image];
imagesHistory=[NSUserDefaults standardUserDefaults];
[imagesHistory setObject:imagesList forKey:@"images history"];
在 didFinishLaunchingWithOptions 我写:(即使我在添加字符串时不需要这样做......)
imagesList = [[NSMutableArray alloc] init];