【发布时间】:2014-12-04 18:46:08
【问题描述】:
我正在尝试通过以下方式从我的 PFUser 对象中获取文件:
PFFile *userImageFile = gaUser[@"@userImage"];
这将返回 nil。
这就是我的方法中的样子:
- (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
我的解析控制台如下所示:
我做错了什么?
【问题讨论】:
-
为什么你用
@userImage而不是userImage来索引字符串?
标签: ios objective-c parse-platform