遍历指定目录下的文件,将复合条件的文件加载到列表(UITableView))

[size=x-large][color=red]本站最新网址:[url]http://www.helmsmansoft.com [/url] 欢迎关注[/color][/size]


- (void)viewDidLoad
{
NSFileManager *fileManager = [[NSFileManager defaultManager] init];
everyTitle = [[NSMutableArray alloc] init];
NSArray *filePaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [filePaths objectAtIndex:0];
// NSLog(@"%@",filePath);
NSDirectoryEnumerator *direnum = [fileManager enumeratorAtPath:filePath];
// NSMutableArray *array = [[NSMutableArray alloc] init];
NSString *fileName;
while ((fileName = [direnum nextObject])) {
if([[fileName pathExtension] isEqualToString:@"pdf"]){

NSArray *strings = [fileName componentsSeparatedByString:@"."];
NSString *fileTitle = [strings objectAtIndex:[strings count]-2];

[everyTitle addObject:fileTitle];

}
}

uiController = [[UIViewController alloc] init];
[uiController setTitle:@"目录"];

navController = [[UINavigationController alloc] initWithRootViewController:uiController];
navController.view.frame = CGRectMake(0, 0, 320, 460);
[self.view addSubview:navController.view];

self.uiController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(tableUpdata)];
//
self.uiController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"刷新列表" style:UIBarButtonItemStyleBordered target:self action:@selector(tableUpdata)];

tableView *tableViews = [[tableView alloc] initWithStyle:UITableViewStylePlain];
tableViews.view.frame = CGRectMake(0, 45, 320, 460);
[tableViews theValue:everyTitle];
[self.view addSubview:tableViews.view];
// [tableViews release];


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值