Swift: declaration 'description' cannot override more than one superclass declaration

前端 未结 4 1695
深忆病人
深忆病人 2021-02-08 10:07

I have a structure of inheritance similar to the one below. I\'m adopting the Printable protocol and diligently override description property. I have encountered a bizarre error

4条回答
  •  一整个雨季
    2021-02-08 10:40

    Same problem for me, solved by doing:

    func customDescription() -> String {
        return ""
    }
    
    override var description: String {
        return customDescription()
    }
    

    so you can override function as many times as you want to

提交回复
热议问题