zoukankan      html  css  js  c++  java
  • ios 修正waring:Method override for the designated initializer of the superclass '-init' not found

    swift引入后,为了使oc和swift更相近,对oc的初始化方法也进行了修正,具体说明,见下面的链接,这个waring的最简单的修正方法是,到相应类的头文件中,去掉在自定义初始化方法后面的 NS_DESIGNATED_INITIALIZER宏。这样系统就不会认为我们定义了designated initializer,仅仅定义了一个convience initializer,就不会报错了!

    重要的解释如下:

    The designated initializer guarantees the object is fully initialised by sending an initialization message to the superclass. The implementation detail becomes important to a user of the class when they subclass it. The rules for designated initializers in detail:

    • A designated initializer must call (via super) a designated initializer of the superclass. Where NSObject is the superclass this is just [super init]. 
    • Any convenience initializer must call another initializer in the class - which eventually leads to a designated initializer. 
    • A class with designated initializers must implement all of the designated initializers of the superclass.

    详细解释:

    http://stackoverflow.com/questions/26185239/ios-designated-initializers-using-ns-designated-initializer

  • 相关阅读:
    WMI介绍
    进程间通信
    回调函数(C/C++)
    漏洞名词介绍
    MD5 详解
    jQuery插件的写法
    node爬虫
    nodejs应用:文件上传
    node开发备注
    node生成自定义命令(yargs/commander)
  • 原文地址:https://www.cnblogs.com/breezemist/p/4829687.html
Copyright © 2011-2022 走看看