Ace Munim
Ace Munim

Reputation: 325

Passing Parsed Data from the Parent view to Child view using segue

i been wanting to pass a data in the textfield of my selected cell, but im getting a full array of that parsed data where i NSLog the data it let me sees what data im passing and also the thing is when i click on any cell it gives me an exception, which is below

[UITableViewController setParentKey:]: unrecognized selector sent to instance 0x7169670
2013-08-29 17:37:58.937 [8322:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewController setParentKey:]: unrecognized selector sent to instance 0x7169670'

As im getting an Array of data from the indexPathForSelectedRow.row i have a MutableArray initialized to catch the passed data in my destination view, my segue code goes like that too, what am i doing wrong here?

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if ([segue.identifier isEqualToString:@"MySegue"]) {
        ChildTableViewController *myNextPage = [segue destinationViewController];
        myNextPage.parentKey = [[parsedData listPopulated]objectAtIndex:self.tableView.indexPathForSelectedRow.row];
        NSLog(@"segue value = %@", [[parsedData listPopulated]objectAtIndex:self.tableView.indexPathForSelectedRow.row]);
    } 
}

Upvotes: 0

Views: 89

Answers (2)

Kevin DiTraglia
Kevin DiTraglia

Reputation: 26078

It looks like you are expecting a ChildTableViewController but receiving a UITableViewController. Make sure your segue is navigating to what you think. You can also add this:

if ([myNextPage isKindOfClass:[ChildTableViewController class]])

That will likely prevent the crash, but if the segue is misconfiguration to go to the wrong view controller, you will need to fix that as well for the segue to do anything.

enter image description here

Upvotes: 1

Anil Varghese
Anil Varghese

Reputation: 42977

Error showing that you are trying to set the parentKey property of UITableViewController in fact UITableViewController doesn't have a property called parentKey. So make sure that you properly set the class of your view controller in storyboard to ChildTableViewController instead of UITableViewController

Upvotes: 0

Related Questions