我正在使用 Parse 的匿名用户功能,以便每个用户都可以创建一个“收藏夹”列表,而不必在应用程序上创建一个帐户。
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.
这是我添加到收藏夹时的代码:
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!!");
}
}];
}
}];
当此代码运行时,Relation 已添加到 Parse 中的 User 表中,但是当我选择“View Relations”时,我又看到了 User。
我是在看东西还是错过了什么?