Skip to content

Instantly share code, notes, and snippets.

@tatey
Created March 23, 2013 23:24
Show Gist options
  • Save tatey/5229724 to your computer and use it in GitHub Desktop.
Save tatey/5229724 to your computer and use it in GitHub Desktop.
class ViewController
include TableSection
def numberOfSectionsInTableView(tableView)
2
end
def numberOfRowsInSection0(tableView)
@data.count
end
def numberOfRowsInSection0(tableView)
@notifications.count
end
def tableView(tableView, cellForRowAtSection0: row)
# Do the stuff for this row in section 0
# return the cell
end
def tableView(tableView, cellForRowAtSection1: row)
# Do the stuff for this row in section 1
# return the cell
end
def titleForHeaderInSection1(tableView)
'Configure Notifications'
end
end
module TableSection
def tableView(tableView, numberOfRowsInSection: section)
selector = "numberOfRowsInSection#{indexPath.section}"
if respondToSelector(selector)
send(selector, tableView)
end
end
def tableView(tableView, cellForRowAtIndexPath: indexPath)
selector = "tableView:cellForRowAtSection#{indexPath.section}"
if respondToSelector(selector)
send(selector, tableView, indexPath.row)
end
end
def tableView(tableView, titleForHeaderInSection: section)
selector = "titleForHeaderInSection#{section}"
if respondToSelector(selector)
send(selector, tableView)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment