私のコードは次のようになります。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex: 0];
docFile_V1 = [docDir stringByAppendingPathComponent:LOG_FILE_V1];
if ([file fileExistsAtPath: docFile_V1] == YES)
{
if(![formatedlogStr writeToFile:docFile_V1 atomically:YES encoding:NSUTF8StringEncoding error:&error])
{
NSLog(@"Error: %@", [error userInfo]);
}
}
これはファイルに書き込むための私のコードですが、残念ながら、ファイルの以前の内容がすべて上書きされます。前の文字列を上書きせずに文字列を書きたい。
例によって、ファイルに書き込みまたは追加する最良の方法を誰かが提案できますか?