我有一个包含字符串形式的图像名称的数组,我想将其转换为图像数组,但出现此错误,我做错了什么?
'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
我的代码:
NSString * immagini = self.chinaTable.images; //unique string
NSArray * arrayImages = [immagini componentsSeparatedByString:@";"];
NSLog(@"The images: %@", arrayImages);// here are strings
/*The images: (
"ArchUrb_PortaGenova1.jpg",
"ArchUrb_PortaGenova2.jpg",
"ArchUrb_PortaGenova3.jpg",
"ArchUrb_PortaGenova4.jpg"
)*/
NSMutableArray * mutableImages =[[NSMutableArray alloc]initWithCapacity:20];
for (id obj in arrayImages){
/*The images: (
"ArchUrb_PortaGenova1.jpg",
"ArchUrb_PortaGenova2.jpg",
"ArchUrb_PortaGenova3.jpg",
"ArchUrb_PortaGenova4.jpg"
)*/
[mutableImages addObject:[UIImage imageNamed:obj]];//here comes the error
NSLog(@"The array mutable is è %@", mutableImages);
}
NSLog(@"The array of images %@", mutableImages);
self.viewImages.animationImages = [NSArray arrayWithArray:mutableImages];
self.viewImages.animationDuration =3;
self.viewImages.animationRepeatCount= 0;
[self.viewImages startAnimating];