开发者

updatefile in application folder

开发者 https://www.devze.com 2023-02-10 20:01 出处:网络
NSString *conent = @\"One\\nnghTwo\\nThree\\nFour\\nFive\"; //save content to the documents directory [conent writeToFile:fileName
NSString *conent = @"One\nnghTwo\nThree\nFour\nFive";
//save content to the documents directory
[conent writeToFile:fileName 
          atomically:NO 
            encoding:NSStringEncodingConversionAllowLossy 
               error:nil];

here is the code to write data in to file

i want to update that file i have 2000 lines to write as application is used.

开发者_如何学JAVA

Thanks for help.


You need to use the NSFileHandle class then writeData, the writing takes place at the file pointer’s current position so use seekToEndOfFile to move the pointer first.

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

精彩评论

暂无评论...
验证码 换一张
取 消