I'm trying to figure out how to use async/await in a Playground using Xcode 12.0 beta / Swift 5.5, but am getting an error every time.
Here's my entire playground code, which is probably wrong:
import Cocoa
import Foundation
if #available(macOS 12.0, *) {
class Foo {
func reversed(_ s: String) async -> String {
Thread.sleep(forTimeInterval: 10)
return String(s.reversed())
}
}
detach {
let foo = Foo()
let result = await foo.reversed("Chowhound")
print("Result is \(result)")
}
}
I'm getting this error:
error: Couldn't lookup symbols: nominal type descriptor for Swift.Task.Handle
Any solution would be great!