gpt4 book ai didi

objective-c - NSFileManager 和 NSFileHandle?

转载 作者:行者123 更新时间:2023-12-04 07:00:46 26 4
gpt4 key购买 nike

我有这个权利吗...

To manipulate files on disk (create, copy, rename etc.) you use NSFileManager

To manipulate file contents (open, read, close etc.) you use NSFileHandle

我只是想确保我理解这一点是正确的。

编辑_001

谢谢,这就是我想到的 Joshua,所以我假设通过使用下面的示例,打开和关闭都由实现自动处理。
fileContents = [NSString stringWithContentsOfFile:fileOnDisk
encoding:NSMacOSRomanStringEncoding
error:&fileError];

加里

最佳答案

或多或少,是的。从文档:

NSFileHandle objects provide an object-oriented wrapper for accessing open files or communications channels.



...虽然 NSFileHandle 不是读/写文件所必需的。您可以使用一行代码且没有句柄将 NSString 写入/读取文件。取决于你想做什么。

关于objective-c - NSFileManager 和 NSFileHandle?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1876222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com