我想在swift中用textension重写NSDictionary中的description属性,但无法弄清楚如何。这在Objective-C中通过使用类别非常容易和常见,我可以这样做:
@implementation NSDictionary (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
NSMutableString *retStr = [NSMutableString string];
retStr = ...
return [retStr copy];
}
@end
我在swift中尝试过:
extension NSDictionary {
override public var description: String {
get {
return ...
}
}
}
但我失败了因为:
Method 'description()' with Objective-C selector 'description' conflicts with getter for 'description' with the same Objective-C selector
然后我不知道该怎么办。请帮帮我~~~
答案 0 :(得分:3)