NSArray *array = [NSArray arrayWithObjects:@"/Users/chentao/Desktop/copy_res/gelato.ds", @"/Users/chentao/Desktop/copy_res/jason.ds", @"/Users/chentao/Desktop/copy_res/jikejunyi.ds", @"/Users/chentao/Desktop/copy_res/molly.ds", @"/Users/chentao/Desktop/copy_res/zhangdachuan.ds", nil]; NSString *copyDes = @"/Users/chentao/Desktop/copy_des"; NSFileManager *fileManager = [NSFileManager defaultManager]; dispatch_async(dispatch_get_global_queue(0, 0), ^(){ dispatch_apply([array count], dispatch_get_global_queue(0, 0), ^(size_t index){ NSLog(@"copy-%ld", index); NSString *sourcePath = [array objectAtIndex:index]; NSString *desPath = [NSString stringWithFormat:@"%@/%@", copyDes, [sourcePath lastPathComponent]]; [fileManager copyItemAtPath:sourcePath toPath:desPath error:nil]; }); NSLog(@"done"); });
dispatch_apply
最新推荐文章于 2024-09-04 21:05:49 发布