VHAsyncRun.h
//
// VHAsyncRun.h
// VHUpload
//
// Created by vhall on 2019/11/7.
// Copyright © 2019 vhall. All rights reserved.
//
typedef void (^VHRun)(void);
void VHAsyncRun(VHRun run);
void VHAsyncRunInMain(VHRun run);
VHAsyncRun.m
//
// VHAsyncRun.m
// VHUpload
//
// Created by vhall on 2019/11/7.
// Copyright © 2019 vhall. All rights reserved.
//
#import "VHAsyncRun.h"
#import <Foundation/Foundation.h>
void VHAsyncRun(VHRun run) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
run();
});
}
void VHAsyncRunInMain(VHRun run) {
dispatch_async(dispatch_get_main_queue(), ^(void) {
run();
});
}
使用
VHAsyncRunInMain(^{
});
VHAsyncRun(^{
});
然并卵…