0

I'm programatically creating x number of UIPicker instances and I want to retrieve the images picked using the didFinishPicking method. I therefore need a way to uniquely identify each picker instance. I'm trying to name each picker in the format picker# where # is the number of the picker instance. But I can't seem to figure out how to name the picker according to an NSString. What I'm basically asking is in the code below how can I name the UIImagePickerController with the NSString pickerName?

-(void) loadLibrary:(UIButton *)sender{
    NSString *pickerName = [NSString stringWithFormat:@"picker%d",pickerCount];

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:picker animated:YES completion:NULL];
}
  • What do you need the picker name for? If you explain your goal, you will get better solutions. – rmaddy Jul 29 '14 at 03:43
  • Sry wasn't very clear. Basically I'm constructing my entire interface programatically based on user input on the previous screen. i.e. for the this case the user defines the number of the image pickers there will be. Each time the user selects an image on the new screen I need to save the image in the documents directory and name it according to the name specified on the previous screen. So far drawing the interface is working fine but now I need to retrieve the images so I need a unique way to identify each picker instance. Pls let me know if you have any suggestions. – Wookies'n'Cookies Jul 29 '14 at 04:04
  • It would be helpful to others (and you) if you updated your question with those details instead of adding it all as a comment. – rmaddy Jul 29 '14 at 04:06

1 Answers1

0

There is no built in way to "name" an image picker.

Since you only present and process one image picker at a time, the simplest solution is to use an instance variable to store your "picker name". Set the ivar when you create the image picker and then make use of the picker name in the image picker delegate method.

rmaddy
  • 314,917
  • 42
  • 532
  • 579