gpt4 book ai didi

ios - objectForKey 不适用于指针

转载 作者:行者123 更新时间:2023-11-28 21:40:22 24 4
gpt4 key购买 nike

在文档中 https://www.parse.com/docs/ios/guide#relations-using-pointers它说在提供的示例中,您可以找到创建游戏的用户

// say we have a Game object
PFObject *game = ...

// getting the user who created the Game
PFUser *createdBy = [game objectForKey:@"createdBy"];

但是当我使用确切的语法时,因为我想在我的“用户”列中填充指针

PFUser *user = [PFUser currentUser];
NSString *username = user.username;



// Inside my queryForTable method so PFObject is returned in
// tableView:cellForRowAtIndexPath:object

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"fromUser = %@", user];
PFQuery *query = [PFQuery queryWithClassName:@"Activities" predicate:predicate];

// Inside tableView:cellForRowAtIndexPath:object

PFUser *createdBy = [object objectForKey:@"user"];

NSLog(@"User to user ---%@", createdBy);

但我得到的只是

User to user ---<PFUser: 0x7ff9024da860, objectId: aOisP569e3, localId: (null)> {
// Nothing here
}

如果我理解正确,我是否还应该在我的用户对象中取回用户名、电子邮件等?

---更新 1---

查看 parse 提供的 Anypic 应用程序,它应该返回类似这样的内容

<PFUser: 0x7f7ff9fafc00, objectId: LfADtx1K2J, localId: (null)> {

// Stuff appears here
displayName = "poopiu";
facebookId = 130941340571204;
profilePictureMedium = "<PFFile: 0x7f7ff9faf500>";
profilePictureSmall = "<PFFile: 0x7f7ff9faf7f0>";
username = I34MBM3WYSB5tjWIIvUvhH5fq;
}

但是我的是空的,即使我有一个名为 username 的列不是未定义的,所以我应该把它放在我的 PFUser 对象中

--更新 2--

这是我从这样的日志记录对象中得到的...

NSLog(@"Object---%@", object);

<Activities: 0x7fbbebf42d20, objectId: rDwYI5Inuk, localId: (null)> {
user = "<PFUser: 0x7fbbee1367e0, objectId: SFL0kVZ17x>";
status = 0;
>

最佳答案

在实例化您的查询 后添加以下方法调用。

[query includeKey: "user"];

默认情况下,查询不会获取被查询的直接对象之外的信息。

关于ios - objectForKey 不适用于指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32384663/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com