Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. class ListCommentsCells: UITableViewCell {
  2.  
  3.  
  4. @IBOutlet weak var tableView: UITableView!
  5. var comments: [Comment]? {
  6. didSet {
  7. println("WHEN SETTING COUNT HERE \(comments?.count)")
  8. tableView.reloadData()
  9. }
  10. }
  11.  
  12. override func awakeFromNib() {
  13. super.awakeFromNib()
  14. tableView.delegate = self
  15. tableView.dataSource = self
  16. }
  17.  
  18. }
  19.  
  20. extension ListCommentsCells: UITableViewDelegate, UITableViewDataSource {
  21. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
  22. println("COUNT CELLFORITEM \(comments?.count)")
  23. let cell = tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
  24. let comment = comments?[indexPath.row]
  25. cell.textLabel?.text = comment?.content
  26. return cell
  27. }
  28.  
  29. func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  30. if let count = comments?.count {
  31. println("COUNT NUMBEROFROWSINSECTION \(count)")
  32. return count
  33. }
  34. return 0
  35. }
  36. }
  37.  
  38.  
  39. OUTPUT when setting comments:
  40.  
  41. WHEN SETTING COUNT HERE Optional(1)
  42. COUNT NUMBEROFROWSINSECTION 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement