Parse - Object does not appear in my relation

95 views Asked by At

I'm using the anonymous user feature of Parse so that each user can create a "Favorite" list and not have to create an account on the app.

When a user is on an item detail page there will be a "Star" image and when selected that object should be added to their Favorite List, which will be a table on another UIViewController.

Here's my code when adding to favorites:

PFQuery * query = [PFQuery queryWithClassName:@"ClassA"];
[query whereKey:@"item_name" equalTo:self.itemLabel.text];
[query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
    if (error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        PFUser * user = [PFUser currentUser];

        self.favRelation = [user relationforKey:@"favorite"];

        [self.favRelation addObject:object];

        [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
            if (error)
            {
                NSLog(@"Error: %@ %@", error, [error userInfo]);
            }
            else
            {
                NSLog(@"Yay!!");
            }
        }];


    }
}];

When this code runs, the Relation was added to my User table in Parse, but when I select "View Relations", I just see the User again.

Am I over looking something or missing something?

0

There are 0 answers