gpt4 book ai didi

ios - getObjectInBackgroundWithId : using pointer [ Parse ]

转载 作者:行者123 更新时间:2023-11-29 12:37:30 25 4
gpt4 key购买 nike

首先,我获取当前用户和与该用户关联的书籍(它是指向书籍 objectId 的指针)。然后我想使用 getobjectinBackgroundWithId 方法找到这本书,然后显示书名。当我将 getObjectInBackgroundWithId:storeUserID 更改为 getObjectInBackgroundWithId:@"f4Dg92xC2" 时,效果非常好!

PFUser *currentuser = [PFUser currentUser];
storeUserID = currentuser[@"connectedBook"]; //Store book id in a string
NSLog(@"%@", storeUserID); // what i get <Book:f4Dg92xC2:(null)>


PFQuery *query = [PFQuery queryWithClassName:@"Book"];
[query getObjectInBackgroundWithId:storeUserID block:^(PFObject *books, NSError *error){
PFObject *bookObject = books[@"bookName"];
NSLog(@"bookName:%@", bookObject);
}];

当我运行它时,带有书名的 NSLog 显示:

Error: bad special key: objectId (Code: 102, Version: 1.2.20) 2014-09-17 23:28:56.529 MyApp[18977:90b] bookName:(null)

提前致谢!

最佳答案

您的评论//Store book id in a string是不正确的。指针不返回字符串对象 ID,它返回对象本身。所以你已经有了它,你不需要调用 getObjectInBackgroundWithId: .

日志<Book:f4Dg92xC2:(null)>甚至告诉你这是 Book实例(不是 NSString 实例)。

关于ios - getObjectInBackgroundWithId : using pointer [ Parse ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25900675/

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