我在 Objective-C 中有一些方法。
我从 Objective-C 父类(super class)创建了一个子类。
现在我想重写 Swift 类中的 Objective-C 父类(super class)方法。
我的代码:
@objc class JobBusinessTableViewCell: AdItemTableViewCell {
override func commonInit() {
super.commonInit()
}
override func updateWithAd(ads: ResponseSimpleAd) {
super.updateWithAd(ads)
}
}
此处 AdItemTableViewCell
是 Objective-C 父类(super class)。
我想在 Swift 中重写 updateWithAd
方法。
我该怎么做?
最佳答案
我找到了答案..但看起来很奇怪..
工作代码:
public final override func update(with ad : ResponseSimpleAd) {
super.update(with: ad)
}
我不明白 swift 中的方法名称更改..但按预期工作...
关于swift - 重写 Swift 文件中的 Objective-C 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40500688/