반응형
Queue
Fist-in Fist-out
Dispatch Queue
- Main Queue
DispatchQueue.main.async{} - Global Queue
Qos(Quality of Service)
1> userInteractive - UI related
2> userInitiated
3> default
4> utility - networking, read write
5> background - download, position update
DispatchQueue.globa(sos: .background).async {} - Custom Queue
let concurrentQueue = DispatchQueue(label: “concurrent”, qos: .background, attributes: .concurrent)
let serialQueue = DispatchQueue(label: “serial”, qos: .background)
Use 2 Queue simultaneously
DispatchQueue.global(qos: .background).async {
let image = downloadImageFromServer()
DispatchQueue.main.async {
self.imageView.image = image
}
}
Sync & Async
asynchronous
synchronous
반응형
'iOS > swift' 카테고리의 다른 글
[swift] 컨트롤러간 화면 전환 (0) | 2021.08.04 |
---|---|
[swift] UICollectionView 사용법 (0) | 2021.08.01 |
URLSession (0) | 2020.07.04 |
Swift error: missing argument label 'name:' in call (0) | 2020.06.08 |
[swift] ViewController간 이동 (0) | 2020.05.01 |