
5. GCD
Running code on different threads
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_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
NSLog(@"Running in the background..."); | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
NSLog(@"Running back on the main thread"); | |
}); | |
}); | |
/* | |
DispatchQueue.global().async { | |
print("Running in the background...") | |
DispatchQueue.main.async { | |
print("Running on the main thread") | |
} | |
} | |
*/ |
'iOS > Objective-C' 카테고리의 다른 글
[Objective-C] atomic vs nonatomic (0) | 2023.04.12 |
---|---|
[Objective-C] Objective-C에서의 메모리 관리 (0) | 2023.04.12 |
[Objective-C] Classes / Paul Hudson의 Objective-C cheat sheet (0) | 2023.04.12 |
[Objective-C] Functions / Paul Hudson의 Objective-C cheat sheet (0) | 2023.04.12 |
[Objective-C] Control flow / Paul Hudson의 Objective-C cheat sheet (0) | 2023.04.12 |