Binding an Ordered Relationship with an NSArrayController

前端 未结 2 757
野性不改
野性不改 2020-12-29 12:35

How does one bind an NSArrayController\'s content to the entities in an ordered to-many relationship?

I have an unordered to-many relationship in my Core Da

相关标签:
2条回答
  • 2020-12-29 13:03

    I came across this discussion while searching to see if there've been any new developments on this front. In a shipping app I currently bind the array controller's content array to orderedSetKey.@array and it works just fine, not sure if I discovered that myself or if someone else suggested it somewhere.

    0 讨论(0)
  • 2020-12-29 13:12

    The fundamental problem is that a Core Data ordered to-many relationship returns an NSOrderedSet, and NSOrderedSet is not a subclass of NSSet. Any array controller bindings that expect an NSSet will fail.

    Tom Fewster has a detailed blog post describing the use of NSValueTransformer to work around this shortcoming, converting between NSOrderedSet and NSArray on the fly. He also provides a sample implementation on Github.

    0 讨论(0)
提交回复
热议问题