You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing in an NSDictionary (which is unordered) to initialize an ordered dictionary doesn't sound valid. Shouldn't this method be replaced by a orderedDictionaryWithObjectsAndKeys: method so that an ordered dictionary can be initialized with multiple ordered keys/values?
The text was updated successfully, but these errors were encountered:
If you look at the code, orderedDictionaryWithContentsOfDictionary: runs this method to create the ordered dictionary:
- (id)initWithContentsOfDictionary:(NSDictionary *)entrys
{
self = [super init];
if (self != nil) {
keys = [[NSMutableArray alloc] initWithArray:entrys.allKeys];
objects = [[NSMutableArray alloc] init];
//Must loop through all keys, since order from NSDictionary is not defined.
for (id key in keys) {
[objects addObject:[entrys objectForKey:key]];
}
pairs = [[NSMutableDictionary alloc] initWithObjects:objects forKeys:keys];
}
return self;
}
This is valid because I first copy over the array of keys. I then iterate through all the keys to create the array of objects. Creating the ordered pairs of keys and objects. If the code was:
Passing in an NSDictionary (which is unordered) to initialize an ordered dictionary doesn't sound valid. Shouldn't this method be replaced by a
orderedDictionaryWithObjectsAndKeys:
method so that an ordered dictionary can be initialized with multiple ordered keys/values?The text was updated successfully, but these errors were encountered: