Unrecognized Selector Sent to Instance UIViewController

Viewed 12088

I keep getting the error:

NSInvalidArgumentException', reason: '-[UIViewController setPhotoCellName:]: unrecognized selector sent to instance

when I enter my prepare for segue call. Currently I have

TabBarController->NavigationController->TableViewController->TableViewController->ViewController

with a UI image on it.

The problem occurs when I try to segue from the second TableView controller to the ViewController. I have the segue setup from the Prototype Cell to the actual ViewController. It enters the segue and crashes. I am trying to pass an NSArray property over to the viewController to be able to use a URL in it and display the UIImage. PhotoInPlace contains the array that Im trying to pass. Here is the code.

myTableViewControllerPhotoLocation.m Code

#import "myTableViewControllerPhotoLocation.h"
#import "FlickrImageViewController.h"

@interface myTableViewControllerPhotoLocation ()
@end

@implementation myTableViewControllerPhotoLocation
@synthesize photoInPlace = _photoInPlace; //Contains NSArray to pass


-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString:@"Photo Display"]){
        NSIndexPath* indexPath = [self.tableView indexPathForCell:sender];
        NSLog(@" Dicitonary = %@", [self.photoInPlace objectAtIndex:indexPath.row]); //Returns the picked cell
        NSLog(@"%@", [self.photoInPlace class]); //returns NSArray
        NSLog(@"%@", [self photoInPlace]); //Returns the array

        [segue.destinationViewController setPhotoCellName:[self.photoInPlace objectAtIndex:indexPath.row]]; 
        //Crashes HERE!
    }
}

FlickrImageViewController.h Code

@property (nonatomic, strong) NSArray* photoCellName;

FlickrImageViewController.m Code

#import "FlickrImageViewController.h"

@interface FlickrImageViewController ()
@end

@implementation FlickrImageViewController
@synthesize photoCellName = _photoCellName; //property declared in header


-(void) setPhotoCellName:(NSArray *)photoCellName{
    if(!_photoCellName)
        _photoCellName = [[NSArray alloc] initWithArray:photoCellName];
    else {
        _photoCellName = photoCellName;
    }
}
2 Answers
Related