且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取iPhone资源文件夹中的文件夹和文件列表?

更新时间:2021-08-07 01:08:44

您可以像这样获得 Resources 目录的路径,

You can get the path to the Resources directory like this,

NSString * resourcePath = [[NSBundle mainBundle] resourcePath];

然后将 Documents 附加到路径中,

Then append the Documents to the path,

NSString * documentsPath = [resourcePath stringByAppendingPathComponent:@"Documents"];

然后你可以使用 NSFileManager的任何目录列表API

NSError * error;
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error];