我在检索附加到 currentUser 的图像时遇到问题。这是我用来保存要解析的信息的代码。
-(IBAction)saveButtonAction:(id)sender {
PFUser *currentUserSave = [PFUser currentUser];
userBioString = userBio.text;
genderFieldString = genderField.text;
ageFieldString = ageField.text;
profilePictureData = UIImageJPEGRepresentation(profilePicture.image, .05f);
PFFile *userProfilePictureFileContainer = [PFFile fileWithData:profilePictureData];
currentUserSave[@"userBioParse"] = userBioString;
currentUserSave[@"userGenderParse"] = genderFieldString;
currentUserSave[@"ageFieldParse"] = ageFieldString;
[currentUserSave setObject:userProfilePictureFileContainer forKey:@"userPictureParse"];
userImageData = UIImageJPEGRepresentation(profilePicture.image, 0.5);
userProfileImageFile = [PFFile fileWithData:userImageData];
[currentUserSave setObject:userProfileImageFile forKey:@"userPictureParse"];
[[PFUser currentUser] saveInBackground];
基本上现在我正在尝试调用信息以加载用户配置文件。继承人我到目前为止(不多)。
PFQuery *queryUser = [PFUser query];
[queryUser whereKey:@"username" equalTo:[[PFUser currentUser]username]];
[queryUser getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error){
PFFile *theImage = [object objectForKey:[PFUser currentUser][@"userPictrueParse"]];
NSData *imageData = [theImage getData];
UIImage *profileImage = [UIImage imageWithData:imageData];
if (profileImage == nil) {
profilePicture.image = [UIImage imageNamed:@"765-default-avatar.png"];
} else {
profilePicture.image = profileImage;
}
}];