iPhone UITableView populating variable rows sections from flat array
Posted
by Biko
on Stack Overflow
See other posts from Stack Overflow
or by Biko
Published on 2010-05-29T12:31:11Z
Indexed on
2010/05/29
12:32 UTC
Read the original article
Hit count: 258
I thought that would be very common and easy iPhone App. In the main app I connect to database, retrieve values from database (NSDate converted to NSString)n and put into single array. The in one of the views I populate UITableView with elements from the array. UITableView is grouped (sections). I step through array to discover number of sections (change section if new day). How do I retrieve correct element of array in cellForRowAtIndexPath? IndexPath.section and IndexPath.row seem useless as row starts count from zero for each section. If number of rows in each section was the same it would have been easy:
[arryData objectAtIndex:(indexPath.row)+indexPath.section*[tblMatchesView numberOfRowsInSection:indexPath.section]];
But number of rows in each section varies... :-)
© Stack Overflow or respective owner