2011-02-14 39 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]; 
相關問題