iphone - writeToFile 失败 - 如何调试它失败的原因(什么工具)?

标签 iphone ios xcode

我从 JSON(使用 SBJson)获取一个 NSDictionary,我想存储它。我正在使用

[liveData writeToFile:localFilePath atomically:YES]

它失败了。数据看起来 像它的所有 NSString、NSDictionary 和 NSArray(“原子地:是”要求)。我在其他地方使用了相同的 localFilePath。

所以我的问题是:我怎样才能找出问题出在哪里?我可以使用哪些工具来了解 writeToFile 失败的原因?日志不显示错误消息。

最佳答案

可能有多种原因:

  • 您正在写入的路径错误,不可写(您没有写入权限),或者父目录不存在(如果 localFilePath 是“/path/to/file.plist"但目录 "/path/to/"不存在,它将失败)
  • liveData 字典确实包含不是 PropertyList 对象的对象。仅限 NSDataNSDateNSNumberNSStringNSArray NSDictionary 对象可以写入属性列表文件(writeToFile:atomically: do 写入 plist 文件,因此字典do 必须只包含 PList 对象才能使该方法成功)

关于iphone - writeToFile 失败 - 如何调试它失败的原因(什么工具)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7519996/

相关文章:

iphone - 在 objective-c 中发送消息时可以转换吗?

iphone - 在 setimage 上收到内存警告

ios - 从 UIWebView 中删除渐变背景?

ios - 设计注册 Controller 拒绝来自 iOS 的 POST

ios - 将 header 放入 pch 文件中有什么区别?

ios - 使用自动布局弹出键盘时调整 UITextView 的大小

iphone - Cocos2d 检测特定 Sprite 上的触摸

iphone - "Plain Style unsupported in a Navigation Item"警告我的自定义条形按钮项目

ios - 应用程序崩溃并出现错误 : -[NSNull length]: unrecognized selector sent to instance

iphone - 苹果错误 LLVM 3.1