I had a look through the existing documentation and couldn't find anything that confirms the behaviour I am seeing.
Starting on iOS 5, CoreData relationships can be ordered and in this case the returned object is a NSOrderedSet.
Can anyone confirm that the order of the objects in the set matches the order in which they have been created?
Cheers, Rog
If you don't sort the order yourself using sortedArrayUsingComparator:
then I believe the objects are sorted in the order in which they are added.
You can also manual set the order with with – insertObject:atIndex:
.
https://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSMutableOrderedSet_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMutableOrderedSet
You should create a NSMutabledOrderedSet with data from your old NSOrderedSet, make your changes and move your data back again:
NSMutableOrderedSet *orderedSet = [[NSMutableOrderedSet alloc] initWithSet:[self.myOrderedSet set]];
[orderedSet insertObject:newObject atIndex:index];
self.myOrderedSet = orderedSet;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With