ManagedModels icon indicating copy to clipboard operation
ManagedModels copied to clipboard

Ordered Relationships, how?

Open helje5 opened this issue 2 years ago • 0 comments

Some support for NSOrderedSet is prepared in the codebase, need to test this and check what actually works.

A problem w/ NSOrderedSet is the lack of an associated type, i.e. it isn't a NSOrderedSet<T>. It can be subclassed in Swift like:

final class OrderedSet<T>: NSOrderedSet

but then the OrderedSet<T> can't be used w/ @NSManaged? (something about OrderedSet<T> can't be used in ObjC).

So the minimal thing would be support for such:

@Model class Group: NSManagedObject {
  @Relationship(inverse: \Item.group)
  var items : NSOrderedSet
}

The target model type could be provided by the inverse.

helje5 avatar Sep 26 '23 12:09 helje5