首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

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

2012-09-05 
遍历指定目录下的文件,将复合条件的文件加载到列表(UITableView))本站最新网址:[url]http://www.helmsmans

遍历指定目录下的文件,将复合条件的文件加载到列表(UITableView))
本站最新网址:[url]http://www.helmsmansoft.com [/url] 欢迎关注

- (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];    }

热点排行