• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Subclassing NSWindowController in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subclassing NSWindowController in Swift


  • Subject: Subclassing NSWindowController in Swift
  • From: Rick Mann <email@hidden>
  • Date: Sat, 18 Oct 2014 20:08:01 -0700

In Obj-C, I typically subclass NSWindowController and override -init to call -initWithNibName:. I do this so the caller doesn't have to worry about how to make one of these window controllers:

@implementation MyWindowController

- (id) init
{
    self = [super initWithWindowNibName: "MyWindow" owner: self]
    ...
    return self;
}

I can't figure out how to do the same in Swift. NSWindowController makes initWithWindow() the only designated initializer, which I must call, which makes it seem like I can't use any of the convenience methods. Apple's own guidance on designated inititalizers is that they should be the ones that take the most parameters.

So, I can load the nib myself, and make the window, and pass that up, but this seems broken. Is it?

--
Rick Mann
email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Subclassing NSWindowController in Swift
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: How does the Swift Darwin module work?
  • Next by Date: bundleForClass in Swift
  • Previous by thread: Re: Toolbar icons, yosemite
  • Next by thread: Re: Subclassing NSWindowController in Swift
  • Index(es):
    • Date
    • Thread