Designated initializers
James Walker
I was looking at the Xcode operation Edit > Convert > To Modern Objective-C Syntax, and what it does with NS_DESIGNATED_INITIALIZER markup. I know, I'm late to the party. I often have a subclass of NSWindowController with one
initializer, say |
|
Quincey Morris
On Oct 4, 2018, at 14:48 , James Walker <list2@...> wrote:
Yes, this is kinda broken for NSWindowController subclasses because “init(windowNibName:owner:)” kinda oughta be a designated initializer but isn’t. What you should be able to do is define “convenience init(parameter:)” but no other inits. That will let all superclass inits (both designated and convenience) get inherited, and your “init(parameter:)” is then allowed to call “across” to another convenience init — “init(windowNibName:owner:)” in this case. So, this compiles: convenience init(parameter: String) { self.init(windowNibName: …) // <— ’self’ not ’super’ because it’s been inherited } |
|