V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cielpy
V2EX  ›  Swift

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

  •  
  •   cielpy ·
    EkkoG · 2014-08-06 22:39:52 +08:00 · 5994 次点击
    这是一个创建于 3549 天前的主题,其中的信息可能已经有所发展或是发生改变。
    更新之前,重写 init 方法前面不用加关键字,beta5 出来后,如果父类 init 方法前有加 required 那么子类也要加 required ,父类没有加,子类在重写的时候需要加 override 。
    在重写 UITableViewCell 子类的时候,遇到这个问题,暂时没找到解决方法,不重写不报错,重写 init 会有这个错误提示,但是没找到 UITableViewCell 的 required members 是哪个,还是要实现什么东西。父类的 init 方法没有 required 关键字,所以子类理应是不用加的,加了还是一样报错。各位最近研究 swift 的,有遇到这个情况吗。
    Class '' does not implement its superclass's required members

    1 条回复    2014-08-18 17:21:33 +08:00
    goldratio87
        1
    goldratio87  
       2014-08-18 17:21:33 +08:00   ❤️ 1
    添加
    required init(coder aDecoder: NSCoder!) {
    super.init(coder: aDecoder)
    }
    方法
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5184 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 908ms · UTC 09:38 · PVG 17:38 · LAX 02:38 · JFK 05:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.