现在我正在上的PDF阅读器应用程序,我可以阅读PDF格式文件,这是目前使用下面的代码的应用程序中,如何让pdf文件按文件夹列出文件夹?
NSArray *userDocuments = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSURL *docementsURL = [NSURL fileURLWithPath:[userDocuments lastObject]];
NSArray *documentsURLs = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:docementsURL
includingPropertiesForKeys:nil
options:NSDirectoryEnumerationSkipsHiddenFiles
error:nil];
NSMutableArray *names = [NSMutableArray array];
NSMutableDictionary *urls = [NSMutableDictionary dictionary];
NSArray *bundledResources = [[NSBundle mainBundle] URLsForResourcesWithExtension:@"pdf" subdirectory:nil];
documentsURLs = [documentsURLs arrayByAddingObjectsFromArray:bundledResources];
for (NSURL *docURL in documentsURLs)
{
NSString *title = [[docURL lastPathComponent] stringByDeletingPathExtension];
[names addObject:title];
[urls setObject:docURL forKey:title];
}
documents = [[NSArray alloc] initWithArray:[names sortedArrayUsingSelector:@selector(compare:)]];
urlsByName = [[NSDictionary alloc] initWithDictionary:urls];
但我的问题是要读取文件夹中的PDF文件的文件夹并存储在分离的阵列, 我的文件夹结构是像下面的图片,
对此的任何帮助将不胜感激..
你有没有试过这种[一个NSBundle mainBundle] pathForResource :@“Images”ofType:nil];因为图像是文件夹的名称。 – Buntylm 2013-04-11 04:42:47
@BuntyMadan它不工作,更重要的是它不是一个数组,它是一个字符串类.. – Venkat 2013-04-11 04:50:48
与此一样,我们可以得到使用URLsForResourcesWithExtension PDF文件后的特定文件夹的路径。没有尝试过的Xcode只是理念与您分享分享 – Buntylm 2013-04-11 04:54:36