How do I make my NSNotification trigger a selector?

Posted by marty on Stack Overflow See other posts from Stack Overflow or by marty
Published on 2010-06-11T02:02:48Z Indexed on 2010/06/11 2:12 UTC
Read the original article Hit count: 331

Here's the code:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *musicURL = [NSURL URLWithString:@"http://live-three2.dmd2.ch/buureradio/buureradio.m3u"];

    if([musicURL scheme])
    {
        MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:musicURL];
        if (mp)
        {
            // save the music player object
            self.musicPlayer = mp;
            [mp release];

            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popBack:) name:@"MPMoviePlayerDidExitFullscreenNotification" object:nil];

            // Play the music!
            [self.musicPlayer play];
        }
    }   
}

-(void)popBack:(NSNotification *)note
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

The selector method never gets called. I just want to pop back to the root menu when the "Done" button is pressed on the movie player. I put an NSLog in the selector to check if it was even being called, nothing. The music plays fine. Any thoughts?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about mpmovieplayercontroller