[Swift Concurrency] Async/await
[iOS - swift] Async, Await 사용 방법
[Swift] async / await & concurrency
// DispatchQueue를 사용한 비동기 처리
DispatchQueue.global.async {
//코드 작성
}
// completionHandler를 사용한 비동기 처리
let task = URLSession.shared.dataTask(with: url, completionHandler: {
data: response, error in
//코드 작성
}).resume()
func loadWebResource(_ path: String) async throws -> Resource
func decodeImage(_ r1: Resource, _ r2: Resource) async thorws -> Image
func dewarpAndCleanupImage(_ i : Image) async thorws -> Image
func processImageData() async thorws -> Image {
let dataResource = try await loadWebResource("dataprofile.txt")
let imageResource = try await loadWebResource("imagedata.dat")
let imageTmp = try await decodeImage(dataResource, imageResource)
let imageResource = try await dewarpAndCleanupImage(imageTmp)
return imageResult
}