rui*_*eco 2 cocoa objective-c nsmutablestring osx-mountain-lion
我正在尝试将字符串写入磁盘:
return [fileContent writeToFile:path atomically:YES encoding:NSUnicodeStringEncoding error:error];
但它总是失败,出现以下错误:
Error Domain=NSCocoaErrorDomain Code=4 "The folder “ddd.csv” doesn’t exist." UserInfo=0xc4a08b0 {NSUnderlyingError=0xc49ba60 "The operation couldn’t be completed. No such file or directory", NSFilePath=file://<path to file>, NSUserStringVariant=Folder}
文件的路径似乎是有效的(我在这里模糊了它),字符串(NSMutableString)肯定不是0长度.此代码曾用于Mountain Lion之前的工作.任何人都可以帮助阐明可能发生的事情吗?
编辑: 
值为path:file://localhost/Users/cocoaster/Downloads/ddd.csv
由于您使用的是保存面板,结果将作为URL返回,因此如果您需要路径,请使用path命令将结果转换为路径:[url path].
或者,您可以使用writeToURL:atomically:如果该版本可用于任何类fileContent.
| 归档时间: | 
 | 
| 查看次数: | 1185 次 | 
| 最近记录: |