title: Swift TableView for iOS
body: <p>I have referred to this <a href="https://stackoverflow.com/questions/24022763/uitableview-in-swift">question</a>, and tried to implement the various answers. I'm doing something dumb, as cellForRow is not being called, and I'm just getting a blank tableView. Are there other data source or delegate methods that I must override?</p>
  
  <p>Thanks</p>
  
  <pre><code>class ViewController: UITableViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
  
          // Do any additional setup after loading the view, typically from a nib.
          //tableView.delegate = self
          //tableView.dataSource = self
  
          tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: "Cell")
  
          //tableView.registerClass(MyTableViewCell.self, forCellReuseIdentifier: "Cell")
          tableView.reloadData()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -&gt; UITableViewCell!  {
          println("cellForRowAtIndexPath")
          println()
          //variable type is inferred
          var cell = tableView.dequeueReusableCellWithIdentifier("CELL") as? UITableViewCell
  
          if !cell {
              cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "CELL")
  
          }
  
          cell!.textLabel.text = "Text Label"
          cell!.detailTextLabel.text = "Detail Text Label"
  
          return cell
      }
  
  
  }
  </code></pre>
  
  <p>UPDATE - The following appears to work.. Thanks for the help!!</p>
  
  <pre><code>class ViewController: UITableViewController, UITableViewDataSource, UITableViewDelegate {
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
  
          // Do any additional setup after loading the view, typically from a nib.
          //tableView.delegate = self
          //tableView.dataSource = self
  
          tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: "Cell")
  
          //tableView.registerClass(MyTableViewCell.self, forCellReuseIdentifier: "Cell")
          tableView.reloadData()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -&gt; Int {
          return 10
      }
  
      override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -&gt; UITableViewCell!  {
          println("cellForRowAtIndexPath")
          println()
          //variable type is inferred
          var cell = tableView.dequeueReusableCellWithIdentifier("CELL") as? UITableViewCell
  
          if !cell {
              cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "CELL")
  
          }
  
          cell!.textLabel.text = "Text Label"
          cell!.detailTextLabel.text = "Detail Text Label"
  
          return cell
      }
  
  
  }
  </code></pre>