アプリの最初の実行時に、いくつかの png をメイン バンドルからドキュメント フォルダーにコピーする必要があります。これらの画像のファイル パスをコア データ エンティティに保存する必要があるため、これが必要です。
私はその方法で試しましたが、うまくいきません。誰かが理由を知っていますか?
// to copy image from main bundle to documents folder
NSString* mainBundleFilePath = [[NSBundle mainBundle] pathForResource:@"SbriciolataDiRicotta" ofType:@"png"];
NSArray *destPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [destPath objectAtIndex:0];
NSData *mainBundleFile = [NSData dataWithContentsOfFile:mainBundleFilePath];
[[NSFileManager defaultManager] createFileAtPath:documentsDirectory
contents:mainBundleFile
attributes:nil];
// to save the file path
NSString*nomeImmagine = [[NSString alloc] initWithFormat:@"SbriciolataDiRicotta"];
NSString *pngFilePath = [NSString stringWithFormat:@"%@/%@.png",documentsDirectory, nomeImmagine];
ありがとう