https://github.com/nzrsky/oddispatch
Header-only GCD/DispatchQueue syntax sugar for ObjC 🚦
https://github.com/nzrsky/oddispatch
dispatchqueue gcd ios objc objective-c
Last synced: 6 months ago
JSON representation
Header-only GCD/DispatchQueue syntax sugar for ObjC 🚦
- Host: GitHub
- URL: https://github.com/nzrsky/oddispatch
- Owner: nzrsky
- License: mit
- Created: 2016-06-14T20:26:53.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-10-19T21:09:33.000Z (over 3 years ago)
- Last Synced: 2024-12-18T20:17:58.029Z (over 1 year ago)
- Topics: dispatchqueue, gcd, ios, objc, objective-c
- Language: Objective-C
- Homepage: https://github.com/Rogaven/ODDispatch.git
- Size: 37.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ODDispatch
[](https://app.travis-ci.com/nzrsky/ODDispatch)
[](https://codecov.io/github/nzrsky/ODDispatch?branch=master)
[](https://cocoapods.org/pods/ODDispatch)
[](https://github.com/Carthage/Carthage)
[](http://cocoadocs.org/docsets/ODDispatch)
[](http://twitter.com/nzrsky)
## Usage
### ODDispatchOnce
```objective-c
@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
```objective-c
// Before
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
}
// After
ODDispatchAfterInMainThread(2, ^{
});
```
### ODDispatchAsyncInMainThread
```objective-c
// Before
dispatch_async(dispatch_get_main_queue(), ^{
});
// After
ODDispatchAsyncInMainThread(^{
});
```
### ODDispatchAsyncInBackgroundThread
```objective-c
// Before
dispatch_async(dispatch_get_global_queue(priority, 0), ^{
});
// After
ODDispatchAsyncInBackgroundThread(^{
});
```
## Installation
ODDispatch is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'ODDispatch'
```
## Author
Alexey Nazarov, alexx.nazaroff@gmail.com
## License
ODDispatch is available under the MIT license. See the LICENSE file for more info.