2015-04-07 68 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设置为委托给他自己的类。这样做后,问题就解决了。