gpt4 book ai didi

swift - 如何通过快速扩展重写 NSDictionary 中的描述属性?

转载 作者:行者123 更新时间:2023-11-28 11:11:30 25 4
gpt4 key购买 nike

我想在 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

那我就不知道该怎么办了。请帮帮我~.~

最佳答案

关于swift - 如何通过快速扩展重写 NSDictionary 中的描述属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34747062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com