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

mdhansen5

macrumors member
Original poster
Nov 22, 2010
43
0
Colorado
I'd like to be able to create a UITableView using Core Data and NSFetched results controller that is divided up into a number of sections, each based on a range of dates, for example: within 5 days, within 10 days and within 20+ days, or something like that. I would be using an NSDate Core Data attribute called "date." I know how to divide the tableview into sections based off of each single date item, but not how to organize it like this. Can anyone help out with this? All I need is a bit of starting point.

Thanks a bunch everyone! I'm pretty new to iOS development, so please bear with me. :)
 
Have a look at Core Data Transient Properties.

Which are only stored in memory not in the database file. Core data has some tricks to keep it's memory use pretty neat, as an object gets pulled out of data base in to memory you a chance to fill in the transient properties. If your using a 5day range then you have a big tolerance if the object stays in memory for a while.

A transient property can be used by NSFetchedResults as the sectionKeyPathName.

So you could take your NSDate that you have stored do some math to it to work out which 5 day range it's in and store that as a transient property. All the Entities with same value in that property will then be in the same table section.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.