1
resposta

Problema ao tentar criar outlet do Table View

Ao tentar conectar a TableView ao View Controller ele retorna : Could not insert outlet connection : Could not find a class View Controller in the language swift

import UIKit

class ViewController: UIViewController, UITableViewDataSource {

    let listaViagens:Array<String> = ["Rio de Janeiro", "Manaus","Porto Alegre"]

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return listaViagens.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: <#T##IndexPath#>)
        cell.textLabel?.text = listaViagens[indexPath.row]
        return cell
    }


}
1 resposta

Oi Viktor, tudo bem?

Tenta fazer o seguinte:

  • Veja se você está linkando o outlet para o ViewController correto.

  • Verifica no storyboard se você setou a classe do ViewController corretamente.

Caso não funcione, me avisa aqui novamente.

Abraço!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software