1
我已經使用此代碼將字符串寫入同一個文件10次。但它覆蓋了每次新推出的以前的數據。我想將新數據追加到舊數據中。覆蓋NSDocumentDirectory中的前一個文件
[@"one" writeToFile:[self returnDocumentsDirectory] atomically:NO encoding:NSASCIIStringEncoding error:nil];
-(NSString *)returnDocumentsDirectory
{
NSArray *DocumentsDirectoryPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [DocumentsDirectoryPath objectAtIndex:0];
NSString *filePath = [path stringByAppendingPathComponent:@"History.txt"];
return filePath;
}