views:

21

answers:

1

Hey, I'm basically trying to retrieve data from SQlite db and populate a tableView from it.

The sql-data-retrieval method creates two arrays. "dataArray" and "SectionArray".

DataArray is filled with data NSObjects.

Uptil this point, i can create the appropriate Section headers.

Here is the problem,

-1 What do i do to make sure that the right objects get into their appropriate sections and not under any other sections (which they seem to be doing). Also the Count(number of rows) in each section differs.

What should the code be in "NumberOfRowsAtIndexPath" and cellForRowAtIndexPath methods

-2 What kind of datasource objects are more suited for this type. I'm simply filling up two NSMutableArrays - dataArray(rows) and SectionArray(Section headers).

A: 

I think you should make many NSArray one for each table header you have created. In NumberOfRowsAtIndexPath you will return the count of the array for the requested section, and in cellForRowAtIndexPath you will choose your array using the section index (as before) and with the row index you will select the row of that array.

MaxFish
Amm, potentially there could be alot of sections. And makin an array for each of it.. wont it have an effect on memory?
Amm, potentially there could be alot of sections. And makin an array for each of it.. wont it have an effect on memory?
I don't think there will be a memory problem with that solution, but in case you want to save a few memory, and your list is static, you can use c arrays. Another solution, In case your list is huge, is to insert al data into a one big nsarray and store only the indexes of the first items in the sections.
MaxFish