ODDispatch
用法
ODDispatchOnce
@import ODDispatch;
// Before
static id singletone;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^(){
singletone = [Singletone new];
});
// After
static id singletone;
ODDispatchOnce(^{
singletone = [Singletone new];
});
ODDispatchAfter
// Before
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
}
// After
ODDispatchAfterInMainThread(2, ^{
});
ODDispatchAsyncInMainThread
// Before
dispatch_async(dispatch_get_main_queue(), ^{
});
// After
ODDispatchAsyncInMainThread(^{
});
ODDispatchAsyncInBackgroundThread
// Before
dispatch_async(dispatch_get_global_queue(priority, 0), ^{
});
// After
ODDispatchAsyncInBackgroundThread(^{
});
安装
ODDispatch 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中
pod 'ODDispatch'
作者
Alexey Nazarov, [email protected]
许可证
ODDispatch 使用 MIT 许可证发布。更多信息请参阅 LICENSE 文件。