【发布时间】:2023-03-11 11:13:02
【问题描述】:
我正在尝试将关注用户的人员列表添加到用户下标题为“关注者”的列中,该列是从发件人标签的 objectatindex 检索的。 代码如下:
-(void)followButton:(id)sender {
UIButton *senderButton = (UIButton *)sender;
NSLog(@"current Row=%ld",(long)senderButton.tag);
PFObject *object = [self.objects objectAtIndex:senderButton.tag];
if (![[object objectForKey:@"followers"]containsObject:[PFUser currentUser].objectId]) {
[[PFUser currentUser] addUniqueObject:object.objectId forKey:@"following"];
[[PFUser currentUser] saveInBackground];
PFUser *otherUser = [self.objects objectAtIndex:senderButton.tag];
NSLog(@"Followed %@", otherUser);
[otherUser addUniqueObject:[PFUser currentUser].objectId forKey:@"followers"];
[otherUser saveInBackground];
// NSLog(@"Followed %@", object);
} else {
[[PFUser currentUser] removeObject:object.objectId forKey:@"following"];
[[PFUser currentUser] saveInBackground];
PFUser *otherUser = [self.objects objectAtIndex:senderButton.tag];
[otherUser removeObject:[PFUser currentUser].objectId forKey:@"followers"];
[otherUser saveInBackground];
}
[self.tableView reloadData];
}
由于某种原因,上面的代码只添加到当前用户的“关注”数组中。再次单击时,该对象将被删除,但没有任何反应。另外,代码
PFUser *otherUser = [self.objects objectAtIndex:senderButton.tag];
[otherUser removeObject:[PFUser currentUser].objectId forKey:@"followers"];
[otherUser saveInBackground];
它什么都不做,同时它应该做的工作是添加到所选行的用户的“Followers”数组中。我究竟做错了什么?目标是获得有效的追随者/追随者行动。我正在使用 PFQueryTableViewController!
【问题讨论】:
标签: ios parse-platform pfuser