蓝懿 知识点总结

来源:互联网 发布:北京java培训学校 编辑:程序博客网 时间:2024/04/30 02:40

蓝懿的日子之     2015年9月13日

​今天北京的天气非常不错,万里无云。

今天刘国斌老师讲的的内容有以下:

​查找文件:

 

if (self.mySwitch.isOn) {//模糊查找

            if ([fileName rangeOfString:self.myTF.text].length>0) {

              [self.paths addObject:filePath];

                [self.tableViewreloadData];

            }

            

            

        }else{//精确查找

            if ([fileName isEqualToString:self.myTF.text]) {

                [self.pathsaddObject:filePath];

                [self.tableViewreloadData];

            }

        }

   递归方法:  

-(void)findFileWithPath:(NSString *)path{

    NSFileManager *fm = [NSFileManagerdefaultManager];

    NSArray *fileNames = [fm contentsOfDirectoryAtPath:path error:nil];

    for (NSString *fileName in fileNames) {

        NSString *filePath = [path stringByAppendingPathComponent:fileName];

        if ([fileName hasSuffix:@".jpg"]||[fileName hasSuffix:@".png"]) {

            

            NSLog(@"%@",filePath);

           [fm removeItemAtPath:filePath error:nil];

            

        }

        

        //判断如果是文件夹需要进到文件夹里面去找

        BOOL isDir = NO;

        if ([fm fileExistsAtPath:filePath isDirectory:&isDir]&&isDir) {

            

            

            [selffindFileWithPath:filePath];

​      }    

    }        

  }  

0 0
原创粉丝点击