开发者

Rewriting problem while loggin in iPhone

开发者 https://www.devze.com 2023-03-03 16:36 出处:网络
i am using following code to log into a file... 开发者_JAVA技巧NSData *dataToWrite = [[NSString stringWithString:@\"log data\"]dataUsingEncoding:NSUTF8StringEncoding];

i am using following code to log into a file...

开发者_JAVA技巧NSData *dataToWrite = [[NSString stringWithString:@"log data"]     dataUsingEncoding:NSUTF8StringEncoding];

NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [docsDirectory stringByAppendingPathComponent:@"fileName.txt"];
[dataToWrite writeToFile:path atomically:YES];

But when this method gets called again...it doest show the last entry...??

Could anyone suggest?

thanks


It is better you try using NSFileHandle , because the write operation to a file on NSData simply a convenience function and can not do a full fledged file operations like appending.

0

精彩评论

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