I want to refer to a class in Swift. In Objective-C I have written this expression: [MyClass class] How does it work in Swift? I need it to assign it to a delegate.
I have tried this: MyClass.class, but get this error: Expected member name following '.'
In swift it's:
let type = MyClass.self
to obtain the type from an instance instead:
var x = MyClass()
let type = x.dynamicType
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With