我正在尝试从 Parse 下载图像,当我从 parse 下载完所有图像后,我的程序崩溃并出现错误:
NSNull getDataInBackgroundWithBlock:progressBlock:]:发送到实例的无法识别的选择器。
我尝试添加一些条件,例如
if(![object objectForKey:@"goal_image"]) //If it is nil => exit
但它仍然在崩溃。这是我的代码:
PFQuery *query = [PFQuery queryWithClassName:@"Goal"];
[query getObjectInBackgroundWithId:[object objectId] block:^(PFObject *object, NSError *error) {
if(!error)
{
PFFile * imageFile = [object objectForKey:@"goal_image"];
if (imageFile) {
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error2) {
if (!error2) {
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Images/Goals/%@",[object objectId]]];
[data writeToFile:jpgPath atomically:YES];
}
} progressBlock:^(int percentDone) {
if (percentDone == 100) {
NSLog(@"Download Completed");
}
}];
}
}
}];