如何获取应用程序文档目录iPhone的URL

问题描述:

此代码是核心数据的一部分. URLsForDirectory ....方法无法在iOS<上运行4,所以我需要知道其他一些要调用的方法/对象.我还将申请文档以供将来参考.谢谢

This code is a part of Core Data. The URLsForDirectory....method does not run on iOS < 4 so I need to know some other methods/objects to call. I would also appriciate documentation for future reference. Thank you

/**
 Returns the URL to the application's Documents directory.
*/
- (NSURL *)applicationDocumentsDirectory
{
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

您可以通过NSSearchPathForDirectoriesInDomains 这将在iOS 2+上运行.

This will work on iOS 2+.