views:

90

answers:

2

This could well be a real stupid question, but I can't seem to sort my Core Data fetched results in the order they were saved to the persistent store.

Effectively, I don't want to sort them at all, but omitting the sort descriptors from the fetch request gets me into all kinds of trouble.

Is what I'm trying to achieve here possible, or will I need to introduce a date attribute into my model and sort on that?

Thanks a bunch.

+1  A: 

I don't believe persistent stores are required to remember the order in which objects were added, so if that's the ordering you want, you'll need to introduce an attribute.

David Gelhar
+3  A: 

There is no inherent order to objects in a Core Data object graph. If you want to keep objects in a particular order, you'll need to do that yourself. You can use an order attribute or a date, but if the order might change, you'll have to be aware of the number of objects that will need to be touched to update the ordering. It can have a significant performance impact for large data sets.

Alex
I feared this was the case. Oh well, it's no biggie adding another attribute. Cheers.
David Foster