Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cellForRowAtIndexPath is never called

Tags:

ios

swift

I have a storyboard which contains UIViewController which has UITableview and UITableViewCell, everything is hooked up properly and I have put all the required code for UIViewController.

When I run the app in the simulator one of the datasource function cellForRowAtIndexPath is never called but numberOfRowsInSection is called

  • "func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int" is called
  • But "func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell" IS NEVER CALLED

Below is my code for view controller:

import UIKit

class DVViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
{

    @IBOutlet var tableView : UITableView?
    var tableData = ["Row 1", "Row 2", "Row 3"]
    let kCellID = "cell"

    override func viewDidLoad()
    {
        super.viewDidLoad()

        self.tableView?.delegate = self;
        self.tableView?.dataSource = self;

        //load cell
        self.tableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: kCellID);
        self.tableView?.reloadData();
    }

    //MARK: Tableview delegates
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
        return self.tableData.count;
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
       //var cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: kCellID)
        let cell : UITableViewCell = UITableViewCell (style: UITableViewCellStyle.Default, reuseIdentifier: kCellID);
        return cell;
    }
}

Can someone suggest why cellForRowAtIndexPath is never called?

like image 665
DP2 Avatar asked Sep 07 '14 23:09

DP2


1 Answers

Here is what I did, uninstalled Xcode 5 & 6 both the reinstalled Xcode 6 only, Ran the project and it WORKED. After 2 days of debugging its the reinstall which did the trick.

like image 191
DP2 Avatar answered Oct 30 '22 04:10

DP2