Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Passing information to another viewController

Hi guys, I`m trying to pass information from one viewController to another, but something is wrong.

Here is what I got so far.

FichaTableViewController (when I click one of the rows, it loads the profile page). At the Prepare Segue part, I have this?

if ([segue.identifier isEqualToString:@"showProfile"]) {
        ProfileViewController *profile = segue.destinationViewController;
        profile.objectId = [self.currentDog valueForKey:@"objectId"];
    }

At the top I have a #import ProfileViewController.h

At the ProfileViewController I tried to query the dog`s information using that objectId but it throws me an error.

I have this

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    PFQuery *query = [PFQuery queryWithClassName:@"dog"];
    [query getObjectInBackgroundWithId:self.objectId block:^(PFObject *object, NSError *error) {
        // Do something with the returned PFObject in the gameScore variable.
        NSLog(@"%@", object);
    }];
}

The error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot do a comparison query for type: __NSArrayI'

1 Answer

i think you should call a if statement in that code block because you has in NSError

 - (void)viewDidLoad

{
[super viewDidLoad];

// Do any additional setup after loading the view.

PFQuery *query = [PFQuery queryWithClassName:@"dog"];

[query getObjectInBackgroundWithId:self.objectId block:^(PFObject *object, NSError *error) {
if(!error)
 {
    // Do something with the returned PFObject in the gameScore variable.

    NSLog(@"%@", object);

     }
}];
 }

Still the same.