简体   繁体   中英

How to write in Swift: [MyClass class]?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM