Reputation: 2169
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?
Upvotes: 23
Views: 7399
Reputation: 299623
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.
Upvotes: 14
Reputation: 540065
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.
Upvotes: 61