Instruments is saying I have a leak from playing my intro movie.  When I click 
on the stack trace it brings me to the second piece of code 
(-[moviePlaybackDidFinish:]),  which is called as a consequence of the 
notification handler setup in the first piece of code 
(-[application:didFinishLaunchingWithOptions:].

This code makes the following assumptions:

1. I don't have to keep a reference to the created controller because it will 
be returned to me in the notification handler.
2. The reference count for the MPMoviePlayerController is incremented when the 
notification object is allocated and initialized.
3. The notification object is auto-released after I return from handling the 
notification.
4. The notification object decrements the reference count of the 
MPMoviePlayerController when it is released.

My question is this: is my technique for releasing the only reference I have to 
the movie controller, which is the notification object, valid?  NOTE: This is 
the new 3.2 SDK movie player controller.

- (BOOL)application:(UIApplication*)application 
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    // start playback of intro movie and watch for notification of playback 
completion
    MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc] 
initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] 
pathForResource:@"intro_movie" ofType:@"mp4"]]];
    moviePlayer.controlStyle = MPMovieControlStyleNone;
    moviePlayer.view.frame = window.bounds;
    [window addSubview:moviePlayer.view];
    [window makeKeyAndVisible];
    [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(moviePlaybackDidFinish:) 
name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
    [moviePlayer play];
    return YES;
}

#pragma mark -
#pragma mark Movie Playback Notification Handler

- (void)moviePlaybackDidFinish:(NSNotification*)notification
{
    // Playback has completed.  Release the player and the associated view-
    // controller and continue with our default application view/controller 
pair.
    [((MPMoviePlayerController*)notification.object).view removeFromSuperview];
    [notification.object release];
    [window addSubview:viewController.view];
}

-Michael
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to