Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save voznesenskym/c5a6dcdf4d167fd44839 to your computer and use it in GitHub Desktop.
Save voznesenskym/c5a6dcdf4d167fd44839 to your computer and use it in GitHub Desktop.
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
var header = tableView.dequeueReusableCellWithIdentifier("userheader") as UITableViewCell
//arrayOfArraysOfContacts is a 2D array of contacts by section
//Each contact has an accountID, and we pull the first one on each section
var id = contactsManager.arrayOfArraysOfContacts[section][0].accountId
//We use the ID to find the correct corresponding account in a dictionary
var account : Account? = AccountsManager.sharedInstance.allAccountsAsDictionaries[id!]
//And populate the header with the name of the account
header.textLabel?.text = account!.name
header.textLabel?.textColor = UIColor.blackColor()
header.contentView.backgroundColor = UIColor.whiteColor()
return header
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment