mah*_*ega 5 casting swift swift3
是否可以将对象转换为存储在成员变量中的类型?
我试过这个:
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'
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用,因为它说“使用未声明的类型'targetClass'”
| 归档时间: |
|
| 查看次数: |
1098 次 |
| 最近记录: |