Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ListCommentsCells: UITableViewCell {
- @IBOutlet weak var tableView: UITableView!
- var comments: [Comment]? {
- didSet {
- println("WHEN SETTING COUNT HERE \(comments?.count)")
- tableView.reloadData()
- }
- }
- override func awakeFromNib() {
- super.awakeFromNib()
- tableView.delegate = self
- tableView.dataSource = self
- }
- }
- extension ListCommentsCells: UITableViewDelegate, UITableViewDataSource {
- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
- println("COUNT CELLFORITEM \(comments?.count)")
- let cell = tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
- let comment = comments?[indexPath.row]
- cell.textLabel?.text = comment?.content
- return cell
- }
- func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- if let count = comments?.count {
- println("COUNT NUMBEROFROWSINSECTION \(count)")
- return count
- }
- return 0
- }
- }
- OUTPUT when setting comments:
- WHEN SETTING COUNT HERE Optional(1)
- COUNT NUMBEROFROWSINSECTION 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement