1
我試圖找到一個數組中項目的索引,該數組包含我創建的名爲TreeItem的結構的項目,但每次我嘗試調用它時都會收到以下錯誤。數組中的錯誤轉換
Cannot convert value of type 'TreeItem' to expected argument type
'@noescape (TreeItem) throws -> Bool'
你能幫我一個人嗎?
編輯(代碼添加): 在一個單獨的文件中的結構被定義: 進口基金會
struct TreeItem {
var Name = String()
var Parent = String()
var HasSons : Bool = false
var Expanded : Bool = false
var Status : Int = 0
init(Parent: String?, Name: String?,HasSons: Bool?, Expanded : Bool?,Status : Int)
{
self.Name = Name!
self.Parent=Parent!
self.HasSons = HasSons!
self.Expanded = Expanded!
self.Status = Status
}
}
在視圖控制器:
var ExpenseCategoryItems = [TreeItem]()
//Fill array with data
func ToggleDeleteButtonStateFunc(){
var TreeSample : TreeView = SomeData
var x = ExpenseCategoryItems.indexOf(TreeSample)
}
在該最後代碼行崩潰不斷髮生。
請張貼一些代碼。很難找到沒有代碼的錯誤。 – Nerkyator
給出崩潰的代碼片段 – Jamil
var x = ExpenseCategoryItems.indexOf(TreeSample) – nasser