码迷,mamicode.com
首页 > 移动开发 > 详细

ios 修正waring:Method override for the designated initializer of the superclass '-init' not found

时间:2015-09-22 18:49:46      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

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

 

ios 修正waring:Method override for the designated initializer of the superclass '-init' not found

标签:

原文地址:http://www.cnblogs.com/breezemist/p/4829687.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!