2015-07-11 109 views
-1

我試過使用swift在xcode中調試我的ios應用程序,一個任務應用程序,但我得到的錯誤「'+ ='不能應用於'[Dictionary]'和'Dictionary'類型的操作數下面的錯誤發生在我的一個函數中,代碼如下。我避開這個錯誤運用「+ =」使用字典式Binary operator'+ ='不能應用於類型'[Dictionary <String,String>]'和'Dictionary <String,String>'的操作數'

代碼:

func taskCreated(task: Dictionary<String, String>) { 
    println("in task created delegate of ViewController") 
    println(task) 

    dataSource[0] += task 

    tableView.reloadData() 
} 

編輯:我的數據源

聲明
var dataSource: [[Dictionary<String, String>]] = [[], []] 
+0

您可以發佈聲明數據源代碼。 – vontell

+0

完成。我發佈了一個編輯。 – ryder2022

回答

1

您想將字典追加到字典數組的數組。選定陣列上使用append()

dataSource[0].append(task) 
+0

謝謝!有效。 – ryder2022

相關問題