我的代码:
dict=[[NSMutableArray alloc]init];
dict= _array;
NSLog(@"%@",dict);
colorimage = [dict objectAtIndex:0];
[_b1 setBackgroundImage:colorimage forState:UIControlStateNormal];
colorimage1 = [dict objectAtIndex:1];
[_b2 setBackgroundImage:colorimage1 forState:UIControlStateNormal];
colorimage2 = [dict objectAtIndex:2];
[_b3 setBackgroundImage:colorimage2 forState:UIControlStateNormal];
colorimage3 = [dict objectAtIndex:3];
[_b4 setBackgroundImage:colorimage3 forState:UIControlStateNormal];
int j=0;
}
-(IBAction)button1:(id)sender{
k++;
[img addObject:colorimage];
[sender setBackgroundImage:[UIImage imageNamed:@"apple.png"] forState:UIControlStateNormal];
[self check];
}
单击button1时,需要将图像数据存储在NSMutableaArray中。我需要比较两个数组。那么如何在Objective-c中的NSMutableArray中存储图像的值。
答案 0 :(得分:0)
将图像存储在数组中:
NSMutableArray * imagesArray =[[NSMutableArray alloc]init];
[imagesArray addObject:[UIImage imageNamed:@"image.png"]];
[imagesArray addObject:[UIImage imageNamed:@"image1.png"]];
[imagesArray addObject:[UIImage imageNamed:@"image2.png"]];
比较两个数组:
if ([array1 isEqualToArray:array2])
{
NSLog(@"equal");
}
else
{
NSLog(@"Not equal");
}