Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I have a tableivew that is populated from an array. Each index of the array is an NSDictionary with a list of food a person has eaten that day. As I am testing this part of my app over the last couple of weeks I am noticing that I am having to scroll down the list for quite some time to get to the current day.

I decided it is best to show the current day at the top of the list in stead of the bottom. Is the best approach just to invert the array that the tableView uses as it's data source? So the last object becomes the first object and so on?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Having the order of the data model be the same as the order of the rows in the table makes things simpler. Simple is good. Obviously it would be possible for you to write a rowDictionaryForIndexPath: method that would have whatever logic is needed to get the row dictionary but simpler is better.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Having the order of the data model be the same as the order of the rows in the table makes things simpler. Simple is good. Obviously it would be possible for you to write a rowDictionaryForIndexPath: method that would have whatever logic is needed to get the row dictionary but simpler is better.

Yes, that is what I thought. So if I invert the array first, before I use it for the data source. Index.row, the 0 row would then match up with the 0th index of the array. Since the array is now inverted the last array index is now the first array index. This seems to be the simplest thing I could think of.

Thanks!
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Huh, So instead of adding the dict to the end of the Array like I am doing, which I would have to invert. Insert the dict to the beginning of the array.

This is why I like this board. I didn't even think of that.

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.