I want to show the data coming from the backend. So let's get an example json file:
{ "fonts": [ { "name": "Helvetica", "styleIdentifier": "H0", "size": 17 }, { "name": "Helvetica", "styleIdentifier": "H1", "size": 14 }, { "name": "Helvetica-Bold", "styleIdentifier": "H0Bold", "size": 17 }, { "name": "HelveticaNeue-Light", "styleIdentifier": "H0Light", "size": 40 } ] }
So, I create a relationship
parameter (many - many) with ordered
. And as I type, I see that it always writes the same to Core Data, but when I try to extract it
configuratation.fonts
, where fonts
is an NSOrderedSet
, I get the elements in completely random order. Am I missing the spec? Or should I sort it out somehow?
__ __ EDIT
Firstly, when I get the data above json, I have a configuration set with an empty font ratio. Then I get this and paste it into the main data with:
NSMutableArray *returnArray = [NSMutableArray new]; for(NSDictionary *fontDictionary in jsonArray) { Font *fontObj = [Font font:fontDictionary inContext:context]; [returnArray addObject:fontObj]; }
And in this array, the data is in the correct order. Then in the configuration object, I add it to the NSOrderedSet
by:
-(void)appendTracks:(NSArray<Font*>*)fontArray { self.fonts = [NSOrderedSet orderedSetWithArray: fontArray]; }
And then I try to extract it just using the link:
configuration.fonts
And at this point, the data is completely out of order.