Reputation: 29795
I am trying to get a file from my PFUser object with by simply:
PFFile *userImageFile = gaUser[@"@userImage"];
This returns nil.
This is what it looks like in my method:
- (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");
}
}];
}
This prints: user image file is nil
My parse console looks like:
What am I doing wrong?
Upvotes: 0
Views: 1005
Reputation: 16865
Since in Parse your column is named userImage
, you should be accessing it with:
PFFile *userImageFile = gaUser[@"userImage"];
instead of
PFFile *userImageFile = gaUser[@"@userImage"];
Upvotes: 4