Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 9, 2012, 03:00 PM   #1
larswik
macrumors 65816
 
Join Date: Sep 2006
UITableView / array question

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?
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote
Old Nov 9, 2012, 05:28 PM   #2
PhoneyDeveloper
macrumors 68020
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
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.
PhoneyDeveloper is offline   0 Reply With Quote
Old Nov 9, 2012, 05:43 PM   #3
larswik
Thread Starter
macrumors 65816
 
Join Date: Sep 2006
Quote:
Originally Posted by PhoneyDeveloper View Post
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!
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote
Old Nov 9, 2012, 09:31 PM   #4
ArtOfWarfare
macrumors 601
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Why not just insert new items at row zero?
ArtOfWarfare is offline   0 Reply With Quote
Old Nov 10, 2012, 12:41 AM   #5
larswik
Thread Starter
macrumors 65816
 
Join Date: Sep 2006
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!
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:33 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC