Q:

Expected method to read dictionary element not found on object of type "class"

I'm trying to implement keyed subscripting for a custom class in Objective-C:
This is what I have in the header:
- (id)objectAtKeyedSubscript:(id <NSCopying>)key;

And this is what I have in the implementation:
- (id)objectAtKeyedSubscript:(id <NSCopying>)key
{
    id result = self.attributes[key];
    return result;  
}

I use it like so:
element[@"href"];

where before I did:
[element objectForKey:@"href"];

where objectForKey was being implemented like so:
- (NSString *) objectForKey:(NSString *) theKey
{
    return [[self attributes] objectForKey:theKey];
}

Something I'm missing? Doing wrong?

A:

The name of the method is objectForKeyedSubscript:, not objectAtKeyedSubscript:.

