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");
}
}];
}
}
}];