PFQuery的奇怪行为

时间:2015-06-09 03:00:01

标签: ios objective-c parse-platform

我正在尝试查找当前用户的所有帖子。当我添加行[query whereKey:@"user" equalTo:[PFUser user]];时,查询甚至没有执行,因为“检索帖子?”永远不会打印到控制台。当我发表评论[query whereKey:@"user" equalTo:[PFUser user]];时,它的工作正常。我做错了什么?

    PFQuery *query = [PFQuery queryWithClassName:@"Post"];

    [query orderByDescending:@"createdAt"];
    [query includeKey:@"filter"];

    [query whereKey:@"user" equalTo:[PFUser user]];

    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        NSLog(@"retrieving posts?");
         ...
    }];

1 个答案:

答案 0 :(得分:1)

我不知道obj-​​c,但Swift中的正确实现是:

query.whereKey("user", equalTo: PFUser.currentUser())