Skip to content

Instantly share code, notes, and snippets.

@probablycorey
Created July 13, 2009 23:51
Show Gist options
  • Save probablycorey/146536 to your computer and use it in GitHub Desktop.
Save probablycorey/146536 to your computer and use it in GitHub Desktop.
require "ListingViewController"
class{..., UI.TableViewController, protocols = {"UITableViewDelegate", "UITableViewDataSource"}}
function dealloc()
super()
end
-- DataSource
-------------
function numberOfSectionsInTableView(tableView)
return 1
end
function tableView_numberOfRowsInSection(tableView, section)
return 3
end
function tableView_cellForRowAtIndexPath(tableView, indexPath)
local cellIdentifier = ("ListingTableViewControllerCell")
local cell = tableView.dequeueReusableCellWithIdentifier(identifier)
cell = cell or UI.TableViewCell.initWithStyle_reuseIdentifier(0, cellIdentifier)
cell.textLabel().setText(tostring(indexPath.row()))
return cell
end
-- Delegate
-----------
function tableView_didSelectRowAtIndexPath(tableView, indexPath)
local cell = tableView.cellForRowAtIndexPath(indexPath)
local text = cell.textLabel().text()
local viewController = ListingViewController.init()
self.navigationController().pushViewController_animated(viewController, true)
end
function tableView_willDisplayCell_forRowAtIndexPath(tableView, cell, indexPath)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment