1

我正在尝试将 NSData 对象写入文件,我使用的代码如下。我遇到的问题是它从不创建文件。

// 创建文件 NSFileManager *filemgr; NSData *数据缓冲区;

filemgr = [NSFileManager defaultManager];

databuffer = [filemgr contentsAtPath: @"/Users/imac/Desktop/mydata.dat" ];

// write to file
databuffer = [filemgr contentsAtPath: @"/Users/imac/Desktop/mydata.dat" ];

[filemgr createFileAtPath: @"/Users/imac/Desktop/mydata.dat" contents:receivedData attributes: nil];

任何帮助将不胜感激。

4

1 回答 1

4

事实证明你可以(我刚刚了解到)。

是一个类似的问题。(您提供的代码也应该可以工作)。

不要忘记在模拟器(而不是 iDevice)中运行它以使其工作。

于 2012-09-24T01:27:27.517 回答