快速迭代(快速遍历 )

    dispatch_queue_t queue=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    NSString * from=@"";
    NSString * to =@"";
    NSFileManager * magr=[NSFileManager defaultManager];
    NSArray * subpaths=[magr subpathsAtPath:from];//获得from路径下的所有文件
    
    
    //同时便利作用
    dispatch_apply(subpaths.count, queue, ^(size_t index) {
        NSString * subpath=subpaths[index];
        NSString * fromFullpath=[from stringByAppendingPathComponent:subpath];
        NSString * toFullpath=[to stringByAppendingPathComponent:subpath];
        [magr moveItemAtPath:fromFullpath toPath:toFullpath error:nil];
    });

posted @ 2016-04-25 14:38  谢小锋  阅读(386)  评论(0编辑  收藏  举报