Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想为我的日志创建一个文件。但是我怎样才能继续将日志写入一个文件?对于第一次使用,我创建文件并保存我的第一个日志。但是我怎样才能在不删除以前的日志消息的情况下继续写入这个文件呢?
NSFileHandle *h = [NSFileHandle fileHandleForWritingAtPath:@"MyFile.log"]; [h seekToEndOfFile]; // log [h writeData:[@"Hello World! 2nd time" dataUsingEncoding:NSUTF8StringEncoding]]; // close when not needed anymore [h closeFile];