Append NSData to a file in Objective C(将 NSData 附加到 Objective C 中的文件)
问题描述
我正在尝试在 iPhone 上下载一个大文件,并在下载后将其保存到磁盘.
I'm attempting to download a large file on the iPhone and save it to disk as it is downloaded.
理想情况下,在:
我想将数据"附加到磁盘上的文件中.
I want to append 'data' to a file on disk.
我查看了 NSData 文档.有写入文件的函数,但我看不到任何要附加到现有文件的内容.
I've checked out the NSData documentation. There are functions to write to a file, but I can't see anything to append to an existing file.
有谁知道我可以如何附加这些数据?非常感谢任何帮助!尼克.
Does anyone know how I can append this data? Any help much appreciated! Nick.
推荐答案
您可以结合使用 NSFileHandle<中的
-writeData:
和 -seekToEndOfFile
方法/code> 类用于将 NSData
写入文件末尾.
You can use a combination of -writeData:
and -seekToEndOfFile
methods from NSFileHandle
class for writing NSData
to the end of a file.
这篇关于将 NSData 附加到 Objective C 中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!