In Swift 2.0, are one-to-many relationships in Core Data still NSOrderedSets?
I cannot seem to be able to cast/downcast appropriately to ever not throw errors.
Does anyone have a simple example of this in Swift 2.0?
Only if you flag the relationship with the option "Ordered". If not, then it's a NSSet
.
I don't agree with the accepted answer because in Swift 2.0 bridging from NSSet
to a Set
happens automatically, so if you can subclass the CoreData entity, you can just write:
@NSManaged var oneToManyOfTypeFoo: Set<Foo>
And then adding and removing elements becomes trivial, because you can just use the insert
and remove
methods from Set
.
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