Search code examples
iosobjective-crubymotion

All rows repeats themself under each section title


I am developing an Rubymotion app. In this app I got a tableview with 10 rows. I want to group these rows by the created_at and display each grouped date in section titles.

It works fine to show these titles but the problem is that all 10 rows appear in under each section title causing there to be 30 rows (3 sections). In other words all 10 rows appears in all sections. What is wrong?

These are my delegates:

def numberOfSectionsInTableView(tableView)

    @tasks.length

  end

  def tableView(tableView, numberOfRowsInSection:section)

    @tasks.length

  end

  def tableView(tableView, titleForHeaderInSection:section)

    @tasks[section]['start_date']

  end

Solution

  • In tableView(tableView, numberOfRowsInSection:section) you must return the actual number of tasks for that section, not the count of all tasks. So @tasks[section].length.