Why does implementing a delegate that has @MainActor declared on it require the object being created to have an "await" keyword?
Here's an example:
class MyClass : NSObject, UIScrollViewDelegate {
override init() {
super.init()
}
}
class MyClass2 : NSObject {
override init() {
super.init()
}
}
class MyTest : BLTestCase {
func xtest_getBrandDataFails() async {
let obj = MyClass(). // expression is async but not marked with await.
let obj1 = await MyClass()
let objc2 = MyClass2()
}
}
UIScrollViewDelegate is declared with @MainActor. And it causes the initialization to require await.
That seems odd to me because my init
methods aren't marked as async
.
It's also odd seeing an await or "suspension point" as stated by the swift concurrency chapter in the swift book, but init is synchronous. Would swift concurrency ever suspend execution here? It seems wrong that it would when I know I don't want a suspension point.