segue.destinationViewController - NSInvalidArgumentException

When a user selects a row in UITableViewController, I want to segue to another viewController and set its UIImageView to a previously set image. For now, I am making it generic - always show /images/en.jpeg.

flickrTVC.m (UITableViewController):

@implementation flickrTVC

...

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"showPhoto"])
        UIImage *photo = [UIImage imageWithContentsOfFile:@"images/en.jpeg"];
        [segue.destinationViewController setDisplayedPhoto:photo];
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"showPhoto" sender:self];
}

I have -(void)setDisplayedPhoto:(UIImage *)image; (it sets self.photo to image) in my photoViewController.h (segue.destinationViewController). I am getting

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setDisplayedPhoto:]: unrecognized selector sent to instance 0x1f5c4a60'

on the following line: [segue.destinationViewController setDisplayedPhoto:photo];. Even with the implementation blank, the error still shows up. I am new to objective-c and, probably, I am just messing some things up.

Any help would be appreciated. Thanks!

Answers


The exception occurs because the object that was there does not define the method setDisplayedPhoto:. This could be because the segue.destinationViewController is currently set to a completely different controller (e.g. for a different view than you think). It could also be that you've defined something similar to that method but not exactly the same; if so then the compiler has probably issued a warning about the setDisplayedPhoto: method call.


Need Your Help

Twitter Stream not working for Tweepy

python twitter tweepy

Using the code below, I'm trying to get a hash tag. It works fine for larger searches like #StarWars, but when i ask for smaller ones it doesn't seem to return anything.

Hiding Row in DataGridView Very Slow

c# .net winforms datagridview

I have a DataGridView in a Winforms app that has about 1000 rows (unbound) and 50 columns. Hiding a column takes a full 2 seconds. When I want to hide about half the rows, this becomes a problem.