In core data if we have multi value relationship, such as when a business can have several keywords, in the subclass NSManagedObject generator, Apple will use NSOrderedSet instead of NSArray.
They are both almost equal except that checking ownership is slightly faster in NSOrderedSet.
Any reason why Apple doesn't use the far more familiar and famous NSArray?
My guess would be: Because NSOrderedSet
manages a collection of distinct elements, similar to NSSet
for unordered relationships.
With NSArray
you could create an object which is related to another object more than once.
From the docs:
You can use ordered sets as an alternative to arrays when the order of elements is important and performance in testing whether an object is contained in the set is a consideration— testing for membership of an array is slower than testing for membership of a 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