Bummer! You must be logged in to access this page.

Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

TableView - Sorting through Dates

I am using CoreData for this project, listing my sorted objects in a UITableViewController chronologically. Each object has a date property, which is used to divide the table in sections. I want, though, that the first section seen by the user is that of the current date, not past dates. For example, if I have three sections (yesterday, today, and tomorrow) I would like that the user first sees the today section and has the option of downloading more previous cells if the wants. Any help would be greatly appreciated! Thanks

4 Answers

Hi Amit, thanks for the reply! Actually I was already able to divide the view in sections and order them chronologically according to their NSDate property, my problem lies in the UIScrollView position, as I would like those cells with dates>=today appearing at the top instead of objects with dates long past. As it is, the top of the scrollview when the view refreshes goes to objects back to objects of past dates first, following the order of the list of stored items.

Hi Amit,

What I actually wanted to do was resolved by an NSPredicate, setting it to a format of @"date >= %@",[NSDate date] , if that is clearer, so that the array only shows objects with present or future but not past dates. Thanks

Mateo