Sla*_*opy 4 iphone xcode core-data ipad
我几乎完成了我在iOS4上运行良好的应用程序,但是当它加载到3.2模拟器时,它崩溃了...
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'
Run Code Online (Sandbox Code Playgroud)
我正在获取应用程序文档目录
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"App.sqlite"];
- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒,谢谢.
用过的
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:@"app.sqlite"];
NSURL *storeURL = [NSURL fileURLWithPath:myPathDocs];
Run Code Online (Sandbox Code Playgroud)
谢谢贾斯汀
该文档提到URLByAppendingPathComponent:
仅在iOS 4及更高版本中可用.您可以通过完成同样的事情NSStrings
有:stringByAppendingPathComponent,然后在完成时转换为URL.
显然URLsForDirectory:inDomains:
也是4.0.查看NSSearchPathsForDirectoriesInDomains()以获取与早期操作系统兼容的替代方案.
归档时间: |
|
查看次数: |
3165 次 |
最近记录: |