2011-02-14 36 views
0
NSString *conent = @"One\nnghTwo\nThree\nFour\nFive"; 
//save content to the documents directory 
[conent writeToFile:fileName 
      atomically:NO 
      encoding:NSStringEncodingConversionAllowLossy 
       error:nil]; 

这里是到文件updatefile在应用程序文件夹

我想更新文件,我有2000行作为应用程序用于写入数据写入的代码。

感谢您的帮助。

+0

你的问题是什么? – 2011-02-14 04:37:02

+0

如何更新该文件 一旦我在该文件中写入1000行 之后,我想添加更多的数据如何添加文本,如果我正在做同样的事情,它会去替换数据。 – GameLoading 2011-02-14 04:40:01

回答

1

您需要使用NSFileHandle类,然后writeData,写入发生在文件指针的当前位置,所以使用seekToEndOfFile首先移动指针。

NSFileHandle *fh = [NSFileHandle fileHandleForWritingAtPath:@"One\nnghTwo\nThree\nFour\nFive"] 
[fh seekToEndOfFile]; 
[fh writeData:data]; 
相关问题