【发布时间】:2017-06-06 09:51:36
【问题描述】:
是否可以将对象转换为存储在成员变量中的类型?
我试过了:
let targetClass = type(of: MyTargetClass)
...
if anyObject is targetClass { // ERROR: use of undeclared type 'targetClass'
let test = anyObject as! targetClass // ERROR: use of undeclared type 'targetClass'
}
但它不起作用,因为它说“使用未声明的类型'targetClass'”
【问题讨论】: