i have storage of the entity "SchedulesItems". and when i try group result of this storage i have trouble with order of keys. for example:
NSMutableArray *keysForDictionary = [[NSMutableArray alloc] init];
NSMutableArray *objectsForDictionary = [[NSMutableArray alloc] init];
NSUInteger index = 0;
for ( EBResponseEventsSchedulesItem *schedulesItem in items ) {
NSDate *date = schedulesItem.date;
if ( ![keysForDictionary containsObject:date] ) {
[keysForDictionary addObject:date];
[objectsForDictionary addObject:[NSMutableArray array]];
}
index = [keysForDictionary indexOfObject:date];
[[objectsForDictionary objectAtIndex:index] addObject:schedulesItem];
}
// in this line array 'keysForDictionary' have right order, just like:
// 25.09.2013
// 26.09.2013
// 27.09.2013
// 28.09.2013
NSDictionary *returnDictionary = [[NSDictionary alloc] initWithObjects: objectsForDictionary forKeys:keysForDictionary];
// but this line array [returnDictionary allKeys] have wrong order, just like:
// 25.09.2013
// 28.09.2013
// 27.09.2013
// 26.09.2013
// but objects which associated with this keys is ok
why sort order of the dictionary is broken?
p.s. sorry for my english - i am from russia