2015-04-07 71 views
3
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {    
      return self.arrayLength 
     } 

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
     let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell") 
     return cell 
} 

並且它打印下一個錯誤:「'tableView'的先前定義在這裏」(定義與之前的值衝突)。他們爲什麼相互衝突?兩個tableView函數彼此衝突

+0

讓我們停止嘗試解決您的問題,請來聊天,我們將看到我們如何解決這裏的鏈接:http://chat.stackoverflow.com/rooms/62028/swift-objectivec -ios –

回答

3

所以我們終於找到了答案。首先是the whole code for the Problem。 (JSON的東西來自SwiftyJson

這裏的問題是,Orkhan忘了在類定義中使用UITableViewDataSource協議,並沒有將tableView.dataSource設置爲委託給他自己的類。這樣做後,問題就解決了。