2017-12-05 14 views
0

私はこのエラーを理解していません。私はこれに関する他の2つの質問を見て、問題を解決しようとしてストーリーボードについたが、成功しなかった。ここに私のコードは次のとおりです。- [UIViewController tableView:numberOfRowsInSection:]:認識できないセレクタがインスタンスに送信されました0x7ff437517770

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:]:認識されていないセレクタを使用すると、ストーリーボードからDataSourceを設定しているので、これが起こっているインスタンスに0x7ff437517770

+0

にクラスとしてHomeを設定し、あなたの店をチェックアウトするのを忘れていると思います。この質問を見てください:https://stackoverflow.com/questions/2455161/unrecognized-selector-sent-to-instance – the4kman

答えて

1

を送りました。しかし、私はあなたがストーリーボードを使用している場合は、Storyboard

enter image description here

関連する問題