您可以在 PFUser 类上创建一个字段:@"watching"
然后将其用作数组,因此每当用户单击要观看的内容时...
[[PFUser currentUser]addObject:objectToWatch.objectId forKey:@"watching"]; // adds it to the array
[[PFUser currentUser]save];
// something about arrays and parse objects, if you're using operations like "addObject" you should save or you'll get errors.
// the other option is to get an NSMutableArray from the array field, edit that, and reassociate it with the @"watching" key ... whichever you prefer
我们现在有一个与要观察的对象关联的 Id 数组。你可以这样查询
PFQuery * query = [PFQuery queryWithClassName:@"ObjectsToWatch"];
[query whereKey:@"objectId" containedIn:[PFUser currentUser][@"watching"]];
[query findObjectsInBackground]; // use a block method though
这只是一种方法,希望对你有帮助