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

  • 相关阅读:
    vue 开发系列 企业微信整合
    MongoDB基础3
    MongoDB基础2
    MongoDB基础1
    SpringBoot MongoDB
    UWSGI
    Nginx
    编译python源码
    Flask部署
    Django个人工作总结
  • 原文地址:https://www.cnblogs.com/breezemist/p/4829687.html
Copyright © 2011-2022 走看看