[英]-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff437517770
I don't quite understand this error or why I am receiving it. 我不太了解这个错误或为什么收到它。 I have had a look at a couple other SO questions on this and have tinkered with my storyboard in attempt to fix the issue, but have had no success. 我已经看过其他一些关于SO的问题,并且对我的情节提要进行了修改,试图解决该问题,但是没有成功。 Here is my code: 这是我的代码:
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
}
}
error: -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff437517770 错误:-[UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例0x7ff437517770
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.