-2

という名前の画像がありmy-imageます。この画像をアプリケーションバンドルに保存できますか?はいの場合、コードまたはパスを教えていただけますか。

今のところ、私は次のコードを持っています–

NSData * imageData = UIImagePNGRepresentation(userSavedImage); //convert image into .png format.
NSFileManager * fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
NSString * documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
NSString * fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",txtImageName.text]]; //add our image to the path

[fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; //finally save the image

NSLog(@"image saved");

しかしそれは節約しています

/Users/tsplmac01/Library/Application Support/iPhone Simulator/4.3/Applications/BC5DE1D8-B875-44BC-AC74-04A17329F29A/.

&アプリケーションバンドルには含まれていません。どうすればいいのか教えてください。

4

1 に答える 1

5

アプリバンドルはアプリに対して読み取り専用であるため、書き込みはできません。

これは、アプリが更新されたときに消去されるため、適切な制限です。代わりに、documentsディレクトリに書き込むことをお勧めします。

于 2011-06-26T11:56:47.410 に答える