Unrecognized selector sent to UIViewController instance

I keep getting the error:

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

when I get into my preparation for calling segue. I am currently

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

with a UI image on it.

The problem occurs when I try to switch from a second TableView controller to a ViewController. I have a segue setting from a Prototype cell for the actual ViewController. He enters the sedge and falls. I am trying to pass an NSArray property to a NSArray in viewController to be able to use the url in it and display a UIImage . PhotoInPlace contains an array that I am trying to transfer. 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! } } 

Code FlickrImageViewController.h

 @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; } } 
+6
source share
2 answers

You think your destination is an object from FlickrImageViewController , but the application does not. Look at the class that you assigned to this controller in your storyboard; according to error, this is a naked UIViewController .

+16
source

It looks like you accidentally got a simple vanilla UIViewController, not a FlickrImageViewController. Maybe you forgot to assign a controller class?

+5
source

Source: https://habr.com/ru/post/922089/


All Articles