私のアプリケーションナビゲーションベース。メモ UIViewController の UItextView。テキストのデータをファイルに書き込んでいます。今、追加モードで書き込む必要があります。以下のコードを試していますが、毎回同じテキスト データで 2 回書き込み、次のテキスト データをファイルに追加する場合は追加しません。
- (void)saveText:(id)sender
{
[self.textview resignFirstResponder];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:@"Notes.txt"];
NSString *savedString = textview.text;
[savedString writeToFile:documentTXTPath atomically:YES];
NSFileHandle *myHandle = [NSFileHandle fileHandleForUpdatingAtPath:documentTXTPath ];
[myHandle seekToEndOfFile];
[myHandle writeData: [savedString dataUsingEncoding:NSUTF8StringEncoding]];
[myHandle closeFile];
}