I Have a container class which stores its data in a dictionary
I would like to enumerate the objects and not the keys.
right now I have code like this
-(NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(__unsafe_unretained id [])buffer count:(NSUInteger)len
{
return [self.container countByEnumeratingWithState:state objects:buffer count:len]; // this isn't working as container is dictionary
}
-(myobject *)objectAtIndex:(int)number // this is the method to retrieve a specific object
{
int i = 0;
for(id key in self.container) {
if (number == i) {
id value = [self.container objectForKey:key];
return value;
}
else i++;
}
return nil;
}
Why not just use the
-allValues
property like this:Additionally,
NSDictionary
is an un-ordered container, so your-objectAtIndex:
method makes no sense.