Array View

Asked

Viewed 67 times

0

I am having trouble running Xcode due to below error:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell: TableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell") as! TableViewCell



    cell.CellTitle.text = TitleList[indexPath.row]
    cell.CellDescription.text = DescriptionList[indexPath.row]

    let imagename = UIImage(named: ImageList[indexPath.row])
    cell.CellImage.image = imagename

    return cell

}





class TableViewController: UITableViewController {

    let ImageList = ["Burj.jpg","Eiffel.jpg","Empire.jpg","Kingdomtower.jpg","Taipei.jpg"]

    let TitleList = ["Burj Khalifa","Eiffel Tower","Empire state Building", "Kingdomtower Tower","Taipei 101",]

    let DescriptionList = ["Dubai, UAA","Paris, France","New Youk, USA", "Jeddai, Sauid Arabia","Taipei Taiwan",]



    override func viewDidLoad() {
        super.viewDidLoad()

         }

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

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return TitleList.count
    }


    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell: TableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell") as! TableViewCell



        cell.CellTitle.text = TitleList[indexPath.row]
        cell.CellDescription.text = DescriptionList[indexPath.row]

        let imagename = UIImage(named: ImageList[indexPath.row])
        cell.CellImage.image = imagename

        return cell

    }

print

  • Run again to cause the error and hover over the objects highlighted by the error. A rectangle with a little arrow should appear. Expand it to see the value of that object. Just gently pass the stroke over the object you can see. Add in the question what showed the submenus. You can usually have a null Nsobject with "broken" or simply empty values caused by a premature dealloc. Which causes type errors exec_bad...

  • 1

    You are probably not registering a cell with the id "cell" in your table, or else the id you are using is different from the one registered.

1 answer

1

You need to define the dentifier of Tableviewcell on the storyboard.

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.