this is a well known snippet, how to select a picture from the iPhone photo library:
- (IBAction)selectExistingPicture {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
Here you can see a screenshot of Instruments (fullscreen).
alt text http://img.skitch.com/20090624-rtqp2mgsnyynkgb97c9e8d2g9c.jpg
Why does it leak? I don’t understand it, because picker is released properly, I think.
The
UIImagePickerControlleris known to leak. If you are going to use it more than once it’s recommended that you reuse a single instance