Upvote:1

Aprove answer

Use ordered relationship. It is mapped to NSOrderedSet.

Upvote:3

I would insert a third entity, let's say BulletsInList, with an attribute, where you can store your ordering Position (1, 2, 3 etc).

Instead of the relationship between List and Bullet you can now build a relationship between Bullet and BulletsInList (one Bullet can be contained in many BulletsInList, one BulletsInList belongs to exactly one Bullet) and another between List and BulletsInList (one List may have many BulletsInLists, one BulletsInList belongs to exactly one List).

In short, the BullettsInList Object contains then: 1 List-Object, 1 Bullet-Object and 1 Number-Attribute for your Position.

More Answer related to the Same Query

Upvote:1

Using ordered relationship it's an option, but iCloud doesn't allow it, so if you plan to use core data on iCloud don't use them, or it will be a pain in the future (based on my own experience).

The solution I recommend it's to extend the List NSManagedObject, let's call it List+Additions, and in that extension, you can have methods which will return the NSSet ordered as you want.


Credit Goes to: stackoverflow.com

Related question with same questions but different answers