I have an NSManagedObject in my iOS app. This object is called Round. In the round, I have a lot to do with a bunch of Person objects.
xCode generates my managed object class using NSSet as the data type of the my-to-many relationship with character-driven objects.
So my Round managed object looks like this:
@interface Round : NSManagedObject { } @property (nonatomic, retain) NSSet* people; @end
However, NSSet is not an ordered collection, and I want to keep the order in NSArray I use to keep these Person objects, as I assign it to my circular managed object.
I tried just converting my NSArray to an NSSet, however the original dialing order is not preserved.
I tried changing the type from NSSet to NSArray in my managed circular object, getting the following error at runtime.
2011-03-11 14: 00: 06.950 SkeetTracker [42782: 207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ** 'Unacceptable type of value for to-many relationship: property = "people"; desired type = NSSet; given type = __NSArrayM; ** value = (
"(entity: Person; id: 0x5bed0c0; data: {\ n firstName = Todd; \ n lastName = McFarlane; \ n round = \" 0x5bf2cb0 \ "; \ n scores = \" \ "; \ n})",
Has anyone ever encountered such a situation and was aware of a solution?
Regards, George
source share