NSDocumentDirectoryを使用して、ユーザーが以下のようなボタンをクリックするだけで、アプリケーションに異なる編集済み画像を保存するたびに画像を保存しています。
-(void)saveImg{
NSData *pngData = UIImagePNGRepresentation(signatureImage);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"myPhoto.png"];
[pngData writeToFile:filePath atomically:YES];
}
そして私は私のイメージを次のような別のクラスで取得しています
-(void)getMyImg{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"myPhoto.png"];
NSData *pngData = [NSData dataWithContentsOfFile:filePath];
UIImage *myImage = [UIImage imageWithData:pngData];
imgView.image = myImage;
}
私の質問は、Apps Documents Directoryを使用するとメモリの問題が発生しますか?たとえば、saveImgメソッドを100回以上クリックすると、アプリDocumentDirectory内に100個の画像が設定されるか、呼び出しごとに以前に保存された画像が新しい画像に置き換えられますか? ( myPhoto.pngと同じ名前を付けているので)、documentsDirectoryはどのように正確に機能しますか?
どんな助けでも事前に感謝されます。