HusseinB
HusseinB

Reputation: 1341

inserting cells at the top of the table with NSFetchedResultsController

my app is using core data and i'm using NSFetchedResultsController in order to populate my table. however, when i insert a new cell it get inserted in the table in an alphabetical order fashion (either ascending or descending - according to the sortDescriptor). i want it to be inserted at the top only. i tried commenting out the sortDescriptor but the app crashes since NSFetchedResultsController requires one. any idea how can i fix that? and i got a question probably not that related. now my app has core data and later i want to add icloud support. so do i have to follow the NSFetchedResultsController approach in my code so that my app will be icloud ready later? or i can follow any approach ? i tried other approaches and the primary problem i posted was fixed as it was more flexible.

Upvotes: 4

Views: 125

Answers (1)

tkanzakic
tkanzakic

Reputation: 5499

Add a createdDate attribute, or something similar to your model (if you don't already have one). After that you can use this attribute in the sortDescriptor to order the NSFetchedResultsController

Upvotes: 2

Related Questions