0

so I am trying to pass data from my cell (populated with queryForTable method) through a segue to another viewController. I am using the prepareForSegue method and my code looks like:

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.identifier isEqualToString:@"profile"]) {

        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        PFObject *object = [self.objects objectAtIndex:indexPath.row];

        //UINavigationController *nav = [segue destinationViewController];
        ProfileViewController *userProfile = [segue destinationViewController]; //(ProfileViewController *) nav.topViewController;
        userProfile.userInfo = object;
    }
}

in my VC I have the property defined:

@property (weak, nonatomic) PFObject *userInfo;

but when I run my code I get the error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setUserInfo:]:
1
  • Did you subclass the view controller in your storyboard to ProfileViewController?
    – John
    Feb 5, 2014 at 6:09

1 Answer 1

0

It looks like the viewController you're pulling out of the segue isn't a ProfileViewController - the error you're getting states:

-[UIViewController setUserInfo:]:

Note UIViewController, not ProfileViewController. This would seem to indicate that your segue's destination viewController isn't exactly what you think it is.

Check your destination viewController's class in your Storyboard. Is it set to ProfileViewController? Is your ProfileViewController embedded inside another viewController (like a navigationController - looking at your commented out code, you seem to have treated it as such before)? If so, you might need to do a big more digging to get a reference to the correct viewController.

1
  • Soooo.... I'm going to feel really stupid right now, but I didn't have my class set up to my storyboard.. But thanks a ton I really appreciate the help! Feb 5, 2014 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.