When adding a relationship within core data, there is an option there to make the relationship "Ordered" (the checkbox). How does core data manage the ordering of relationship or what is the default ordering (if there is any)?
Say, I got an Header and Detail entities. I specified a "To-Many" relationship (Header can have many Detail) and checked the "Ordered" check box. When I do a fetch on the "Header", I can specify which attribute it will be ordered -- I'm ok with this and my question is not related to this. I put the result on a tableview and when user tapped detail disclosure, I will display the Detail in another tableview. I don't use a FetchResultController to display details, I just access the details via relationship. This means I don't specify any ordering for the details. My question is related to this, how does core data manage the ordering of the Details? Since I specified the relationship as "Ordered", does it really order the details by default? If yes, what is the default order behavior?
Inverse relationships enable Core Data to propagate change in both directions when an instance of either the source or destination type changes. Every relationship must have an inverse. When creating relationships in the Graph editor, you add inverse relationships between entities in a single step.
Fetched Properties in Core Data are properties that return an array value from a predicate. A fetched property predicate is a Core Data query that evaluates to an array of results.
Use Core Data to save your application's permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device. To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container.
Core Data is a graphical and persistence framework, which is used in Apple devices with operating systems macOS and iOS. Core Data was first introduced in Mac OS X 10.4 Tiger and iOS with iPhone SDK 3.0.
The ordered
setting just creates the property as an NSOrderedSet
within that entity. So essentially, they are ordered based on the order in which they are added.
You can sort the set yourself using sortedArrayUsingComparator:
More info: https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSOrderedSet_Class/Reference/Reference.html
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