views:

83

answers:

1

Hi all,

I'm using the standard Apple moviePlayer sample code and have customized it to play only podcasts like:

-(IBAction)playPodcast:(id)sender{
movieURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@", podcastURI]];
if (movieURL)
{
    if ([movieURL scheme])  // sanity check on the URL
    {

        // initialize a new MPMoviePlayerController object with the specified URL, and
        // play the movie
        [self initAndPlayMovie:movieURL];
    }
}   
    }

-(void)initAndPlayMovie:(NSURL *)movieURL1
{
// Initialize a movie player object with the specified URL
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL1];
if (mp)
{
    // save the movie player object
    self.moviePlayer = mp;
    [mp release];

    // Apply the user specified settings to the movie player object
    [self setMoviePlayerUserSettings];

    // Play the movie!
    [self.moviePlayer play];
}
   }

I'm calling "playPodcast" function on click of a tableView cell button. But application is crashing at [self.moviePlayer play]; and it's giving me an error:

 *** -[PodcastTableViewCell playPodcast]: unrecognized selector sent to instance 0x10c9b90
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[PodcastTableViewCell playPodcast]: unrecognized selector sent to instance 0x10c9b90'

where PodcastTableViewCell is my podcast tableviewcell identifier.

Can anybody please help?

Thanx in advance.

A: 

As far as I see at the moment, the problem lies within you PodcastTableViewCell. Apparently it tries calling playPodcast without the necessary parameter. you now have two possibilities:

  • add a second playPodcast Method without parameter
  • change your playPodcast call withing your PodcastTableViewCell like this: [probablyAViewcontroller playPodcast:self]

I think the real issue here is wether to use IBAction Methods or not. Or if you have functionality that you use in several places (i.e. from IBActions as well as from within your code) it's a matter of design / like / dislike where to place the "actual" code.

what I usually do is, putting non-UI related code within non IBAction methods..

hope i could help a bit.

samsam
Done.. You were right, the problem was with the method call.. Thanx samsam..
neha