1
當我嘗試通過斯威夫特嵌套類的功能期待AnyClass
參數我獲得以下編譯器錯誤:不能通過斯威夫特嵌套類作爲AnyClass參數
Expected member name or constructor call after type name
有沒有一種辦法可以解決上面的錯誤,並通過嵌套類作爲參數?
func getInfo(type: AnyClass) -> UInt32
{
var outPropCount: UInt32 = 0
let properties: UnsafeMutablePointer<objc_property_t> = class_copyPropertyList(type, &outPropCount);
free(properties)
return outPropCount
}
public class Outer: NSObject
{
public class Data: NSObject
{
public var groups: [Int] = []
}
}
public class Data: NSObject
{
public var groups: [Int] = []
}
let o = getInfo(Outer) // works
let d = getInfo(Data) // works
let i = getInfo(Outer.Data) // fails to compile