Voici le code ci-dessous. Il télécharge une image miniature et essaie ensuite de créer une image basée sur le chemin du fichier miniature. Mais il me donne l'erreur EXC_BAD_ACCESS à l'appel de la méthode "imageWithContentsOfFile". Alors que EXC_BAD_ACCESS adresse le code essayant d'accéder à un objet qui a été libéré, je ne sais probablement pas quel objet il pourrait être. Toute aide serait appréciée!iOS [UIImage imageWithContentsOfFile: filePath] Problème EXC_BAD_ACCESS
NSBlockOperation *completionOperation = [NSBlockOperation blockOperationWithBlock:^{
if([[NSFileManager defaultManager] fileExistsAtPath:operation.destinationPath ]){
NSString *key = [[MEURLCacheKeyRegister sharedRegister] cacheKeyForURL:operation.fileUrl];
UIImage *image = [UIImage imageWithContentsOfFile:operation.destinationPath];
}else{
DDLogDebug(@"Thumbnail file doesn't exist at %@", operation.destinationPath);
}
}
}];
AFDownloadRequestOperation *requestOperation = [FileServerDownloadUtils downloadOperationForURL:operation.fileUrl
destinationPath:operation.destinationPath
completion:completionOperation];
[self.fileSyncQueue addOperation:requestOperation];
Quelle ligne elle plante et que faites-vous avec la variable 'image' après le chargement dans le bloc d'achèvement? – Abhinav
Salut Abhinav, il s'est écrasé à la ligne UIImage * image = [UIImage imageWithContentsOfFile: operation.destinationPath]; – user744641
opération est un objet NSOperation personnalisé BTW. – user744641