简体   繁体   English

-[UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例0x7ff437517770

[英]-[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

This is happened because you have set DataSource from Storyboard. 发生这种情况是因为您已从Storyboard设置了DataSource but I think you have forgot to set Home as Class in Storyboard 但我认为您忘了在Storyboard中将Home设置为Class

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [UIViewController tableView:numberOfRowsInSection:]: 无法识别的选择器发送到实例 - [UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance -[UIViewController tableView:numberOfRowsInSection:]: 无法识别的选择器发送到实例 - -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance tableview无法正常工作 - [UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器发送到实例 - tableview not working - [UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance &#39;NSInvalidArgumentException&#39;-[UIViewController tableView:numberOfRowsInSection:]-无法识别的选择器已发送到实例 - 'NSInvalidArgumentException' - [UIViewController tableView:numberOfRowsInSection:] - unrecognized selector sent to instance -[UIViewController tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例0x7fc748e37ea0&#39; - -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fc748e37ea0' tableView:numberOfRowsInSection:]: 无法识别的选择器发送到实例 - tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 获取-[SearchViewController tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例 - Getting -[SearchViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance numberOfRowsInSection - 无法识别的选择器发送到实例问题 - numberOfRowsInSection - unrecognized selector sent to instance issue 无法识别的选择器发送到实例 - UIViewController - Unrecognized selector sent to instance - UIViewController [UIViewController setRecipeName:]:无法识别的选择器已发送到实例 - [UIViewController setRecipeName:]: unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM