我不太明白这个错误或我收到它的原因。我已经看了几个关于此问题的其他SO问题并且在我的故事板上修改了试图解决问题,但没有成功。这是我的代码:
class Home: UIViewController, UITableViewDataSource, UITableViewDelegate {
var images = [String]()
var names = [String]()
func getNames(array: inout Array<String>){
for dict in State.event {
array.append(dict["name"] as! String)
}
}
func getImages(array: inout Array<String>){
for dict in State.event {
let cover = dict["cover"] as! NSDictionary
let pictureURL = cover["source"] as! String
array.append(pictureURL)
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return State.token.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
getNames(array: &names)
getImages(array: &images)
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
let url = URL(string: images[indexPath.row])
let imageData = try? Data(contentsOf: url!)
cell.eventImage.image = UIImage(data: imageData!)
cell.eventName.text = names[indexPath.row]
return cell
}
}
错误: - [UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器发送到实例0x7ff437517770