Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mriddle committed Apr 27, 2016
1 parent 17c28bb commit 8486e41
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Checklists/ChecklistViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ class ChecklistViewController: UITableViewController {

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("ChecklistItem", forIndexPath: indexPath)

let label = cell.viewWithTag(1000) as! UILabel
let item = items[indexPath.row]
label.text = item.text

configureCheckmarkForCell(cell, item: item)
configureTextForCell(cell, withChecklistItem: item)
configureCheckmarkForCell(cell, withChecklistItem: item)
return cell
}

Expand All @@ -49,20 +47,23 @@ class ChecklistViewController: UITableViewController {
let item = items[indexPath.row]
item.checked = !item.checked

configureCheckmarkForCell(cell, item: item)
configureCheckmarkForCell(cell, withChecklistItem: item)
}

tableView.deselectRowAtIndexPath(indexPath, animated: true)
}

func configureCheckmarkForCell(cell: UITableViewCell, item: ChecklistItem) {
func configureCheckmarkForCell(cell: UITableViewCell, withChecklistItem item: ChecklistItem) {
if item.checked {
cell.accessoryType = .Checkmark
} else {
cell.accessoryType = .None
}
}


func configureTextForCell(cell: UITableViewCell, withChecklistItem item: ChecklistItem) {
let label = cell.viewWithTag(1000) as! UILabel
label.text = item.text
}
}

0 comments on commit 8486e41

Please sign in to comment.