UIImagePickerController objective-c

I have 4 buttons and 4 imageviews and i want to be able to change the image using UIImagePickerController. I can only do this for one button and image view.
how should i do it for 4?
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    UIImage *image1 = [info objectForKey:UIImagePickerControllerOriginalImage];

    
    NSData *data = UIImagePNGRepresentation(image1);
    NSString *myGrabbedImage = @"myGrabbedImage.png";
    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectory = [path objectAtIndex:0];
    NSString *fullPathToFile = [documentDirectory stringByAppendingPathComponent:myGrabbedImage];
    
    [data writeToFile:fullPathToFile atomically:YES];
    [[self firstImageView]setImage:image1];

    [self dismissViewControllerAnimated:YES completion:nil];
    
}

Comments

Sign In or Register to comment.