gpt4 book ai didi

ios - 如何使用 Parse 从 pfobject 获取 pffile

转载 作者:行者123 更新时间:2023-11-28 18:59:46 25 4
gpt4 key购买 nike

我试图通过以下方式从我的 PFUser 对象中获取文件:

PFFile *userImageFile = gaUser[@"@userImage"];

这将返回零。

这是我的方法中的样子:

- (void)getRemoteImageAndSaveLocalWithObjectId:(NSString *)objectId andType:(NSString *)type{
if ([type isEqualToString:@"user"]) {
PFQuery *query = [GAUser query];
// I tried the include key but I get an error.
//[query includeKey:@"userImage"];
[query getObjectInBackgroundWithId:objectId block:^(PFObject *object, NSError *error) {
GAUser *gaUser = (GAUser *)object;
// this is nil
PFFile *userImageFile = gaUser[@"userImage"];

if (userImageFile){
[userImageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
NSLog(@"in get data");
if (!error) {

NSLog(@"remote image name: %@",data.debugDescription);

UIImage *image = [UIImage imageWithData:data];


}else{

NSLog(@"there was an error");
}
}];
}else{
NSLog(@"user image file is nil");
}

}];
}

打印:user image file is nil

我的解析控制台看起来像:

enter image description here

我做错了什么?

最佳答案

因为在 Parse 中你的列被命名为 userImage,你应该通过以下方式访问它:

PFFile *userImageFile = gaUser[@"userImage"];

代替

PFFile *userImageFile = gaUser[@"@userImage"];

关于ios - 如何使用 Parse 从 pfobject 获取 pffile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27301624/

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