解析PFUser之后

时间:2015-12-25 15:03:03

标签: ios objective-c parse-platform pfuser

我试图在我的 ios9 项目中使用解析进行跟进操作,但在检索 PFUser 从解析使用objectId可以任何人帮助我(问题是在用户添加当前用户的用户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];
}

1 个答案:

答案 0 :(得分:1)

假设您的问题与长时间运行有关(根据您的评论):

您的查询正在主线程上执行,因为您调用了[query findObjects]。请改用findObjectsInBackgroundWithBlock,然后将所有代码放在回调中。