MPMediaickerController memory leak

Posted by Joe on Stack Overflow See other posts from Stack Overflow or by Joe
Published on 2010-04-01T07:13:54Z Indexed on 2010/04/01 7:33 UTC
Read the original article Hit count: 333

Filed under:
|

This is code from Apple's Addmusic example.

MPMediaPickerController *picker =
    [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];

picker.delegate                        = self;
picker.allowsPickingMultipleItems    = YES;
picker.prompt                        = NSLocalizedString (@"Add songs to play", "Prompt in media item picker");

// The media item picker uses the default UI style, so it needs a default-style
//        status bar to match it visually
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES];

[self presentModalViewController: picker animated: YES];
[picker release];

I'm using this code in my app and the Leaks instrument highlights a leak on the line:

[self presentModalViewController: picker animated: YES];

I think that this is because this line retains a reference to picker which cannot be subsequently released.

Is there any way around this?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c