1
是否有可能將對象轉換爲存儲在成員變量中的類型?類型鑄造變量中的類型
我已經試過這樣:
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’」