【问题标题】:What should I put on the whereKey:@"objectId"?我应该在 whereKey:@"objectId" 上放什么?
【发布时间】:2014-03-05 17:38:44
【问题描述】:

我正在使用 iOS。

如果我在 whereKey:@"" 中插入 @"objectId"。我收到一条错误消息:错误的特殊键:objectId。

这是我的代码:

PFQuery *findFriends = [PFUser query];
[findFriends whereKey:@"objectId" equalTo:friendsID];
[findFriends selectKeys:@[@"firstname",@"lastname"]];
[findFriends findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
        NSLog(@"%@", objects);
    }
}];

friendsID 是一个 NSString,带有来自当前用户关注的用户的 objectId。

谢谢!

【问题讨论】:

  • 我过去比较过objectId,你的'friendsID'变量肯定是objectId字符串吗?您能否在查询之前显示您如何签名或 NSLog(@"%@",friendsID) 并告诉我值。
  • @Logan 是的,friendsID 是一个 objectId。值:qvcFLA9vHs
  • @Logan NSString *friendsID = [[friends objectAtIndex:0] objectForKey:@"toUser"];
  • 我刚刚使用了您的确切代码,没有任何问题。从字面上看,复制并粘贴到 Xcode 中,它运行良好。不知道你为什么会得到这个。您是否有某种可能阻止访问的用户 ACL?
  • “friends”数组是字符串数组还是 PFUsers 数组?

标签: ios parsing objectid pfquery


【解决方案1】:

问题是你的friendsID实际上不是一个字符串,我猜它是一个PFUser。如果是这种情况,那么一种方法就是使用 this。

PFUser * toUser = [friends[0] objectForKey:@"toUser"];
PFQuery * findFriends = [PFUser query];
[findFriends whereKey:@"objectId" equalTo:toUser.objectId];
[findFriends selectKeys:@[@"firstname",@"lastname"]];
[findFriends findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
        NSLog(@"%@", objects);
    }
}];

【讨论】:

  • 成功了!谢谢你洛根(:
猜你喜欢
  • 2013-10-02
  • 1970-01-01
  • 2021-06-15
  • 2016-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-21
  • 1970-01-01
相关资源
最近更新 更多