On 24 Jun, 2014, at 11:36 pm, Quincey Morris <[email protected]> wrote:
> On Jun 24, 2014, at 07:55 , Sean McBride <[email protected]> wrote: > >> I guess it's omission could be a bug, but assuming not, Sketch gets a >> compiler warning if you tag its own designated initializer (init) with >> NS_DESIGNATED_INITIALIZER, since it doesn't call one of super's designated >> initializers. > > It doesn’t look like a bug per se, since the old NSWindowController pattern > is grandfathered into the Swift world. However, tagging a subclass ‘init’ as > designated will break it. > > I believe you can solve it if you implement ‘initWithWindow:’ as a designated > initializer in the subclass too (just calling super). In that case, your > subclass will inherit ‘initWithWindowNibName:’ as a convenience initializer, > so it can be called by your subclass ‘init’ — though I would assume only as > ‘self initWithWindowNibName:’, not as ‘super initWithWindowNibName:’. > I had a go at this in a playground. If you just inherit and make no initializers, you're fine (obviously). if you write your own designated initializer (ie no 'convenience') keyword, you must call one of the superclasses designated initializers using super.init( .. ) but you don't need to implement/override either of the initWithWindow: or initWithCoder: methods as your initializer can call the superclass one If you write your own convenience initializer then you must, first, implement at least one designated initializer in your class, just overriding initWithWindow: and calling super is enough for that or writing your own designated initializer which calls one of the superclass ones works too. >> I was trying not to mention 10.10 due to any NDA (though Apple seems more >> lax about it recently) > > Nothing I said was under NDA, since all the information came from the Swift > book and the WWDC videos, which are not under NDA this year. In fact, I > haven’t downloaded 10.10 or Xcode 6 yet. Since the answer to your question > isn’t under NDA, I think we can assume the question was legal too. :) > > My reading of the NDA this year is it's been relaxed to allow the developer community to ask questions, try things out and learn from each other. I'm sure you can break it, but I didn't feel identifying what the two designated initializers were in NSViewController got close to that point. _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
