【发布时间】:2012-12-13 17:24:12
【问题描述】:
如何将 *.pdf 所有 pdf 从我的 iphone 导入到我的应用程序中,像这样添加音乐文件。 http://developer.apple.com/library/ios/#samplecode/AddMusic/Introduction/Intro.html 。提前致谢。iphone 开发新手。非常感谢任何帮助。
NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
NSFileManager *mgr = [[NSFileManager alloc] init];
NSArray *allFiles = [mgr contentsOfDirectoryAtPath:bundlePath error:NULL];
for (NSString *fileName in allFiles)
{
if ([[fileName pathExtension] isEqualToString:@"pdf"])
{
NSString *fullFilePath = [bundlePath stringByAppendingPathComponent:fileName];
// fullFilePath now contains the path to your pdf file
// DoSomethingWithFile(fullFilePath);
NSLog(@"file: %@",fullFilePath);
}
}
NSURL *url = [[NSBundle mainBundle] URLForResource:@"" withExtension: @"pdf"];
NSLog(@"File: %@",url);
【问题讨论】:
-
从您的代码看来,这个 pdf 文件已经存在于您的应用程序包中,您只想知道如何获取它?
-
是的,上面的代码就是为此,但我想查看 iphone 中的所有 pdf,我该如何更改或者我需要使用什么路径?