Question

So I am trying to integrate my image accessor code into my application but for some reason I keep running into this exception:

2014-04-14 21:20:34.876 1k[21130:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewController setParent:]: unrecognized selector sent to instance 0x10ab7e8a0'

When I debug, the error occurs when I try to set tableViewController.parent=self; (this is the way that the later controllers can access the UploadViewController, The code for UploadViewController that is calling the segue looks like this

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"ToTableView"]) {
    UINavigationController *navigationController = [segue destinationViewController];
    TableViewController *tableViewController = navigationController.viewControllers[0];
    tableViewController.parent = self;
    tableViewController.groups = (NSArray *)sender;
}}

And the header file of TableViewController looks like this:

@interface TableViewController : UITableViewController <AssetsAccessorDelegate,      UIAlertViewDelegate> {
      AssetsAccessor *assetsAccessor;
}

@property (nonatomic, retain) id parent;
@property (nonatomic, retain) NSArray *groups;

@end

I had first found this functionality through Github and now am trying to integrate it into my code I don't understand why it is now giving me this problem.

This error can happen for so many different reasons that I am really at a lost for how to approach this.

Was it helpful?

Solution

I'm betting tableViewController isn't really a TableViewController. Put a breakpoint at this line of code:

tableViewController.parent = self;

...then in the debugger window, type the following:

po tableViewController

po means "print object". You should see something like this:

<TableViewController: 0x100615120>

If instead it looks something like this:

<UITableViewController: 0x100615120>

...then that's your problem. If so, then navigationController.viewControllers[0] isn't the right class. Look at where in the code (or storyboard) that is set up.

OTHER TIPS

navigationController.viewControllers[0] is an instance of UITableViewController, not your TableViewController class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top