-2
A
回答
0
錯誤信息是有點誤導,但嘗試分配它之前初始化數組:
var c: Array<PostCategory> = []
......或者......
var c = Array<PostCategory>()
0
我打賭你PostCategory
是一個struct
。顯然結構數組不能轉換爲任何數組。這很奇怪,因爲所有類型都符合Any協議。
如果將PostCategory
更改爲class
,則應該正常工作。您可能需要爲該類創建一個新的初始化程序,因爲類不會像結構那樣爲您提供相同的初始化程序。
+0
是,PostCategory是一個結構體,有什麼等同於任何結構體的 –
實際的任務在哪裏? – Alexander
[爲什麼不是\ [SomeStruct]可轉換爲\ [Any \]?](http://stackoverflow.com/questions/37188580/why-arent-somestruct-convertible-to-any) – Hamish