开发者

Rewriting problem while loggin in iPhone

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜