views:

104

answers:

1

I am currently trying to make a sectioned table like this:

Section 1: Entry 1 Entry 2 Entry 3

Section 2: Entry 4 Entry 5 Entry 6

Section 3: Entry 7 Entry 8 ...

However, using this code:

Event *lists = (Event *)[eventList objectAtIndex:indexPath.row];

accessStatement = "select * from DatabaseName";

[self findEvents]; // Code that builds each object's strings from database

cell.textLabel.text = lists.name;

Section 1: Entry 1 Entry 2 Entry 3

Section 2: Entry 1 Entry 2 Entry 3

Section 3: Entry 1 Entry 2 ...

It keeps on repeating itself. How do I make the index so that it continues in each section rather than restarts?

Thanks in advance.

A: 

The row will start from zero at each section. You can get your index into the database by multiplying the number of rows you want per section with the indexPath.section parameter:

Event *lists = (Event *)[eventList objectAtIndex:(indexPath.section * 3) + indexPath.row];

Claus

Claus Broch
Thanks - I've already come up with an alternate solution, but I'll look at yours as well.
Chris