CoreData应用程序目录在iOS3上崩溃 [英] CoreData application directory crashes on iOS3

查看:188
本文介绍了CoreData应用程序目录在iOS3上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了我的应用程序,在iOS4上运行良好,但是当它加载到3.2模拟器它崩溃与..

  2010-12-21 07:54:32.052 App [14044:207] ***  -  [NSPathStore2 URLByAppendingPathComponent:]:无法识别的选择器发送到实例0x4d2b640 
2010-12-21 07:54:32.054 App [ 14044:207] ***由于未捕获异常NSInvalidArgumentException终止应用程序,原因:'*** - [NSPathStore2 URLByAppendingPathComponent:]:无法识别的选择器发送到实例0x4d2b640'
pre>

我得到应用程序文档目录

  NSURL * storeURL = [[self applicationDocumentsDirectory] ​​URLByAppendingPathComponent:@App.sqlite]; 

- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

任何帮助都会很棒,谢谢。

解决方案

文档提到 URLByAppendingPathComponent:仅在iOS 4及更高版本中可用。您可以通过使用 NSStrings stringByAppendingPathComponent:,然后在完成后转换为网址。



显然 URLsForDirectory:inDomains:也只有4.0。查看 NSSearchPathsForDirectoriesInDomains(),以便与以前的操作系统兼容。


I have nearly finished my application that works well on iOS4, however when loading it into the 3.2 simulator it crashes with..

2010-12-21 07:54:32.052 App[14044:207] *** -[NSPathStore2 URLByAppendingPathComponent:]: unrecognized selector sent to instance 0x4d2b640
2010-12-21 07:54:32.054 App[14044:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPathStore2 URLByAppendingPathComponent:]: unrecognized selector sent to instance 0x4d2b640'

I am getting the application Document Directory with

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"App.sqlite"];

- (NSURL *)applicationDocumentsDirectory {
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

Any help would be great, thanks.

解决方案

The documentation mentions that URLByAppendingPathComponent: is only available in iOS 4 and later. You can accomplish the same thing by using NSStrings with stringByAppendingPathComponent:, and then converting to a URL when done.

Apparently URLsForDirectory:inDomains: is 4.0-only as well. Check out NSSearchPathsForDirectoriesInDomains() for an alternative that's compatible with earlier OSes.

这篇关于CoreData应用程序目录在iOS3上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆