requestSomething() { fetchSomethingA(id: 1, compeltion: { [weak self] a in // ॲཧΛॻ͘ self?.fetchSomethingB(id: a, compeltion: { [weak self] b in // ॲཧΛॻ͘ self?.fetchSomethingC(id: b, compeltion: { c in // ॲཧΛॻ͘ }) }) }) } }
= 0 // தུ func requestSomething() async { let a = await fetchSomethingA(id: 1) let b = await fetchSomethingB(id: a) let c = await fetchSomethingC(id: b) // ॲཧΛॻ͘ Task.detached(priority: nil, operation: { @MainActor in // @MainActor ͰϝΠϯεϨουͰߋ৽Ͱ͖Δʁ self.number = c }) } }
WWDC 2021 Meet async/await in Swift https://developer.apple.com/videos/play/wwdc2021/10132 WWDC 2021 Meet AsyncSequence https://developer.apple.com/videos/play/wwdc2021/10058 WWDC 2021 Use async/await with URLSession https://developer.apple.com/videos/play/wwdc2021/10095 WWDC 2021 Bring CoreData concurrency to Swift and SwiftUI https://developer.apple.com/videos/play/wwdc2021/10017