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)
我错过了什么?做错了?
| 归档时间: |
|
| 查看次数: |
3814 次 |
| 最近记录: |