UR1からDocumentDirectoryにすべての画像をダウンロードして、後でゲームの一部として使用できます。次のコードを使用して画像をダウンロードしています
NSArray* path = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString* docPath = [path objectAtIndex:0];
docPath = [docPath stringByAppendingPathComponent:@"ImageName.png"];
UIImage* image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[array objectAtIndex:o] valueForKey:@"Image_Question"]]]];
NSData* imgData = UIImagePNGRepresentation(image);
[imgData writeToFile:docPath atomically:YES];
また、アプリケーションで使用するために取得する場合は、次のコードを使用できます
UIImage* imageFormDoc = [UIImage imageWithContentsOfFile:docPath];
また、ドキュメントディレクトリから画像を削除する場合は、次のコードを使用できます。
[[NSFileManager defaultManager] removeItemAtPath:docPathエラー:&error];
docPathは、画像付きのドキュメントディレクトリのフルパスです。詳細については、NSLogを使用して印刷できます。強調されたテキスト