我试图在我的ios9项目上使用解析执行一个跟踪操作,但是当从使用objectId的解析中撤回PFUser时,有人能帮我吗(问题是在将当前用户的用户ID添加到所跟踪的用户中)
- (IBAction)followButtonAction:(id)sender {
PFQuery * query = [PFUser query];
[query whereKey:@"objectId" equalTo:_a.userId];
NSArray *objects = [query findObjects];
PFUser *user= objects.firstObject;
//add the user ID for the cell we are following to the array of followed items in the user class in parse
[[PFUser currentUser] addUniqueObject:_a.userId forKey:@"followed"];
[[PFUser currentUser] saveInBackground];
//add the user ID to the user that the user followed
[user addUniqueObject:[PFUser currentUser].objectId forKey:@"followers"];
[user saveInBackground];
}发布于 2015-12-25 21:20:50
假设您的问题是关于长期运行的操作(根据您的评论):
您的查询正在主线程上执行,因为您调用了[query findObjects]。相反,使用findObjectsInBackgroundWithBlock,然后将所有代码放在回调中。
https://stackoverflow.com/questions/34463896
复制相似问题