在类"对象"类型的对象上找不到字典元素的预期方法

ped*_*ios 2 objective-c subscript ios

我正在尝试在Objective-C中实现自定义类的键控下标:

这就是我在标题中的内容:

- (id)objectAtKeyedSubscript:(id <NSCopying>)key;
Run Code Online (Sandbox Code Playgroud)

这就是我在实施中所拥有的:

- (id)objectAtKeyedSubscript:(id <NSCopying>)key
{
    id result = self.attributes[key];
    return result;  
}
Run Code Online (Sandbox Code Playgroud)

我这样使用它:

element[@"href"];
Run Code Online (Sandbox Code Playgroud)

在我之前的地方:

[element objectForKey:@"href"];
Run Code Online (Sandbox Code Playgroud)

其中objectForKey的实现方式如下:

- (NSString *) objectForKey:(NSString *) theKey
{
    return [[self attributes] objectForKey:theKey];
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么?做错了?

rma*_*ddy 5

方法的名称objectForKeyedSubscript:不是objectAtKeyedSubscript:.