-
-
Save sturdysturge/2706162f779c8176ed38182a710c69a3 to your computer and use it in GitHub Desktop.
This file contains 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
import SwiftUI | |
struct ContentView: View { | |
func forTryAwait() async { | |
do { | |
for number in try await asyncFunc() { | |
print("\(number.howHigh)") | |
} | |
} catch { | |
fatalError(error.localizedDescription) | |
} | |
} | |
func asyncFunc() async throws -> [Counter] { | |
return [Counter(howHigh: 10), Counter(howHigh: 7), Counter(howHigh: 4)] | |
} | |
var body: some View { | |
EmptyView() | |
.task { | |
await forTryAwait() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment