Search code examples
iosobjective-cnsarraynsmanagedobjectnsset

Can I replace NSSet with NSArray in an NSManagedObject subclass?


In a subclass of NSManagedObject, "To Many" relationships are generated as an NSSet. However I need the objects in the collection to be in a correct order, is there any potential errors if I replace NSSet with NSArray? Or is there any other ways to achieve that?


Solution

  • Mark your relationship as ordered in the object model designer, and then generate your subclass. It will have an NSOrderedSet as the class of the property for your to-many relationship, which you can use for similar purposes as an NSArray. Get familiar with the differences between the two before you proceed.