Skip to content

Instantly share code, notes, and snippets.

@twe4ked
Forked from tatey/gist:5229724
Last active December 15, 2015 21:19
Show Gist options
  • Save twe4ked/5324733 to your computer and use it in GitHub Desktop.
Save twe4ked/5324733 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 numberOfRowsInSection1(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#{section}:"
if respondsToSelector(selector)
send(selector, tableView)
end
end
def tableView(tableView, cellForRowAtIndexPath: indexPath)
selector = "tableView:cellForRowAtSection#{indexPath.section}:"
if respondsToSelector(selector)
send(selector, tableView, indexPath.row)
end
end
def tableView(tableView, titleForHeaderInSection: section)
selector = "titleForHeaderInSection#{section}:"
if respondsToSelector(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