gpt4 book ai didi

ios - -[UIViewController tableView :numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff437517770

转载 作者:行者123 更新时间:2023-11-28 12:13:27 26 4
gpt4 key购买 nike

我不太明白这个错误或者我为什么会收到它。我已经查看了其他几个关于此的 SO 问题,并修改了我的 Storyboard以试图解决该问题,但没有成功。这是我的代码:

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

最佳答案

发生这种情况是因为您从 Storyboard 设置了 DataSource。但我认为您忘记了将 Home 设置为 Storyboard 中的 Class

enter image description here

关于ios - -[UIViewController tableView :numberOfRowsInSection:]: unrecognized selector sent to instance 0x7ff437517770,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47654345/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com