Created
April 1, 2014 16:23
-
-
Save edom18/9917611 to your computer and use it in GitHub Desktop.
[Objective-C] GCDについての備忘録 ref: http://qiita.com/edo_m18/items/2f8c6bde4492ef116ed0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dispatch_queue_t queue = dispatch_queue_create("com.hoge.queue", [attribute]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 3秒後に処理を実行 | |
| dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)); | |
| dispatch_after(time, dispatch_get_main_queue(), ^{ | |
| // do something. | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| size_t iterations = 10; | |
| dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITIY_DEFAULT, 0); | |
| dispatch_apply(iterations, queue, ^(size_t i) { | |
| NSLog(@"Current i: %lu", i); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment