从库中选择的图像可以存储在一个数组中吗?

Can the selected images from library be stored in an array?

我已经在相机和库上构建了一个示例项目。现在,我的问题是我可以将从库中选择的图像存储到数组中吗?我正在使用这段代码。

UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
[self.arrImages addObject:chosenImage];

现在通过设置断点,我开始知道,在我的数组中总是存储 1 个对象,即使我选择了多次图像也是如此。

任何人都可以告诉我我该怎么做吗?

非常感谢任何帮助。

试试这个。

-(void)viewDidLoad {

//declare before NSMutableArray *_mutableArray;
_mutableArray = [[NSMutableArray alloc] init];
}

.....

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
 //dismiss UIImagePickerController
[picker dismissViewControllerAnimated:YES completion:Nil];

//take image from anywhere
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

//store image into NSMutableArray
[_mutableArray addObject:image];


}