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 68030
 
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 603
 
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

Similar Threads
thread Thread Starter Forum Replies Last Post
OSX Reinstall Question: Will new install see raid array on internal drives? BillsFanNC Mac OS X 10.7 Lion 2 Apr 14, 2013 07:11 PM
Resolved: Array Sorting Question larswik iPhone/iPad Programming 2 Sep 3, 2012 08:56 PM
UITableView populating help LARRYSE iPhone Tips, Help and Troubleshooting 1 Aug 22, 2012 01:47 PM
Sort Array Question larswik iPhone/iPad Programming 11 Aug 4, 2012 06:33 PM
UITableView ?? Fritzables iPhone/iPad Programming 2 Jul 1, 2012 09:50 PM

Forum Jump

All times are GMT -5. The time now is 08:24 AM.

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

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