I want to rewrite the description property in NSDictionary by textension in swift, but can't figure how. This is very easy and common in Objective-C by using category, I can just do as this:
@implementation NSDictionary (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
NSMutableString *retStr = [NSMutableString string];
retStr = ...
return [retStr copy];
}
@end
I tried in swift as:
extension NSDictionary {
override public var description: String {
get {
return ...
}
}
}
But I failed because:
Method 'description()' with Objective-C selector 'description' conflicts with getter for 'description' with the same Objective-C selector
Then I don't know what should I do. Please help me ~.~
Extensions can add new functionality to a type, but they cannot override existing functionality.