Kevin Sylvestre
Kevin Sylvestre

Reputation: 38012

NSFetchedResultsController Separated into Sections based on Calculated Attribute

Is it possible to create an NSFetchedResultsController separated into sections based on the output of a method? For example, if the Core Data model is a person, can you separate them into generation-x, generation-y, baby boomers, etc. (when date-of-birth is the core data field and the function for evaluating the generation is relatively trivial?).

Upvotes: 1

Views: 342

Answers (2)

ma11hew28
ma11hew28

Reputation: 126329

You can also do this with a category method on NSDate as explained by @jbrennan in Using custom sections with NSFetchedResultsController?

Upvotes: 2

Rog
Rog

Reputation: 18670

Yes. Create a transient property in your object model so you can make the appropriate calculations and assign the result to it. Then simply ask the fetchedResultsController to use this property for the table sections.

Upvotes: 3

Related Questions