Coredata how to change default NSSet to NSMutableArray

CoreData one-to-many by default generates NSSet

how to change NSSet

to NSMutableArray

? I am trying to change it manually, but I get the error:

 _NSFaultingMutableSet filteredArrayUsingPredicate:]: unrecognized selector sent to instance 0x1ed35e40'

      

+3


source to share


1 answer


NSSet

has a method allObjects

that returns NSArray

.

To get NSMutableArray

, you can do this:

NSMutableArray *array = [NSMutableArray arrayWithArray:myCoreDataObject.mySet.allObjects];

      

Note: the order is not guaranteed to be the same every time (sets are not ordered). If order is important to you, consider NSOrderedSet

.

See also docs on NSSet

:



https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html

PS:

The reason you are getting the error is:

NSSet

(or _NSFaultingMutableSet

for that matter) doesn't have a method called filteredArrayUsingPredicate

.

+12


source







All Articles