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.
我想将文本写入文件,但在搜索解决方案时,我到处都发现“read-append-write”,但该文件对于 iOS 设备的内存来说太大了,它会冻结并重新启动。有没有其他解决方案可以做到这一点?
您可以使用NSFileHandle该类,以便不必将整个文件读入内存(顺便说一句,这对任何文件都是不好的做法!):
NSFileHandle
NSFileHandle *fh = [NSFileHandle fileHandleForWritingAtPath:@"/path/to/file.ext"]; [fh seekToEndOfFile]; NSData *data = // obtain an NSData somehow [fh writeData:data]; [fh closeFile];