lundi 13 juillet 2015

CoreData ordered relationship is fetched in the wrong order (different order)

Mornin' everybody, I have a problem with ordered relationships in CoreData. My expectation is that when I define a relationship as ordered, it will be fetched in exactly the order in which it has been saved the last time.

The problem is that I have defined an ordered relationship and I checked that this relationship is saved in the correct order but my result is that the relationship has the wrong order after it's fetched next time.

Did I miss something here or does CoreData not provide this feature?

My parent entitiy:

@interface WorkstepMO : NSManagedObject 

@property (nonatomic, strong) NSOrderedSet *documents

@end

My child entity:

@interface DocumentMO : NSManagedObject

@end

This is a one-to-many relationship and its ordered arrangement is set to true.

Now when I fetch an object of type WorkstepMO the documents are not fetched in the order I saved them to the store. I also didn't find a column in the created SQLite DB to give information about the sort order so I wonder how CoreData should have the ability to give me my documents in that order I saved them.

Does anyone have experienced that before?

Aucun commentaire:

Enregistrer un commentaire