-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
When I use objectForKey:atIndex for a given key with e.g. atIndex=2 i want to get the
2nd occurance of exactly that key.
but, xmlElementDictionaryForKey compares the absolute index of the rootArray with
the relative index given by, let's say objectForKey:atIndex.
Suggestion:
-original-
- (NSMutableDictionary *)xmlElementDictionaryForKey:(NSString *)key atIndex:(NSInteger)index {
for (NSInteger i = 0; i < self.rootArray.count; i++) {
NSMutableDictionary *dictionary = [self.rootArray objectAtIndex:i];
if ([dictionary objectForKey:key] && (index == NSIntegerMax)?YES:(i == index)) {
return [dictionary objectForKey:key];
}
}
return nil;
}
-modified-
- (NSMutableDictionary *)xmlElementDictionaryForKey:(NSString *)key atIndex:(NSInteger)index {
int keyMatch = 0;
for (NSInteger i = 0; i < self.rootArray.count; i++) {
NSMutableDictionary *dictionary = [self.rootArray objectAtIndex:i];
if ([dictionary objectForKey:key] && ((index == NSIntegerMax)?YES:(keyMatch == index))) {
return [dictionary objectForKey:key];
}
if ([dictionary objectForKey:key]) {
keyMatch++;
}
}
return nil;
}
Best regards
Metadata
Metadata
Assignees
Labels
No labels