实现过程:
1。在应用程序的Info.plist文件中添加Application supports iTunes file sharing键,并将键值设置为YES。
- (void)viewDidLoad {
[super viewDidLoad];
_array_FileName=[[NSMutableArray alloc]init];
_array_FilePath=[[NSMutableArray alloc]init];
[self getFile];
}
/**
* 获取NSDocuments文件下的pdf文件
*/
-(void)getFile{
NSString *DocPath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
file_manager=[[NSFileManager alloc]init];
NSArray *subPaths=[file_manager subpathsAtPath:DocPath];
for (NSString *path in subPaths) {
NSArray *arry=[path componentsSeparatedByString:@"."];
NSString *last=[arry lastObject];
if ([last isEqualToString:@"pdf"]) {
[_array_FilePath addObject:[DocPath stringByAppendingPathComponent:path]];
[_array_FileName addObject:[path lastPathComponent]];
NSLog(@"filepath:%@ ----- fileName:%@",path,[path lastPathComponent]);
}
}
[_mytableview reloadData];
}