我正在尝试在Objective-C中实现自定义类的键控下标:
这就是我在标题中的内容:
- (id)objectAtKeyedSubscript:(id)key;
这就是我在实施中所拥有的:
- (id)objectAtKeyedSubscript:(id)key { id result = self.attributes[key]; return result; }
我这样使用它:
element[@"href"];
在我之前的地方:
[element objectForKey:@"href"];
其中objectForKey的实现方式如下:
- (NSString *) objectForKey:(NSString *) theKey { return [[self attributes] objectForKey:theKey]; }
我错过了什么?做错了?
方法的名称objectForKeyedSubscript:
不是objectAtKeyedSubscript:
.