I am first doing add observer call
followed by remove observer in the notification function.
I am certain that removerObserver is called as I see it on the stack However, the app crashes as if a bad memory reference is left over in the notification center.
I think there are 2 possiblities
I am hitting an apple bug
My sequence of invocation is wrong
Here is my code from playvideo function
//Initialize a MPMoviePlayerController object with the movie. moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(movieReadyPlayMovieNow:) name:MPMoviePlayerContentPreloadDidFinishNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(moviePlayBackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
Here is Notification called when the movie is done preloading
- (void) movieReadyPlayMovieNow:(NSNotification*)notification {
@try { if(moviePlayer != nil){
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerContentPreloadDidFinishNotification object:moviePlayer];[moviePlayer play];
}
} @catch(id exception) { NSLog(@"Error playing."); } }