cielpy
V2EX  ›  Swift

beta5 更新后,重写 init 方法遇到一个问题,求助。

  •  
  •   cielpy ·
    EkkoG · Aug 6, 2014 · 6613 views
    This topic created in 4325 days ago, the information mentioned may be changed or developed.
    更新之前,重写 init 方法前面不用加关键字,beta5 出来后,如果父类 init 方法前有加 required 那么子类也要加 required ,父类没有加,子类在重写的时候需要加 override 。
    在重写 UITableViewCell 子类的时候,遇到这个问题,暂时没找到解决方法,不重写不报错,重写 init 会有这个错误提示,但是没找到 UITableViewCell 的 required members 是哪个,还是要实现什么东西。父类的 init 方法没有 required 关键字,所以子类理应是不用加的,加了还是一样报错。各位最近研究 swift 的,有遇到这个情况吗。
    Class '' does not implement its superclass's required members

    1 replies    2014-08-18 17:21:33 +08:00
    goldratio87
        1
    goldratio87  
       Aug 18, 2014   ❤️ 1
    添加
    required init(coder aDecoder: NSCoder!) {
    super.init(coder: aDecoder)
    }
    方法
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5897 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 02:41 · PVG 10:41 · LAX 19:41 · JFK 22:41
    ♥ Do have faith in what you're doing.