iOS Designated Initializers : Using NS_DESIGNATED_INITIALIZER

后端 未结 3 710
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 00:54

We have this new macro being introduced in XCode 6 : NS_DESIGNATED_INITIALIZER

I searched on the net, but couldn\'t really find any good documentation as to how to u

3条回答
  •  臣服心动
    2020-12-01 01:17

    Designated initializers define how we structure our initializers when subclassing; they are the “canonical initializer” for your class. It guaranteed to be reliable regardless of which designated initializer in the superclass chain you call, and will always go from furthest ancestor to furthest descendant.

    A designated initializer does not define what initializer you should use when creating an object. It's very explained in https://blog.twitter.com/2014/how-to-objective-c-initializer-patterns.

提交回复
热议问题