Re: [Xcode 6 beta3][Swift] NSDocument addWindowController failing inexplicably
Re: [Xcode 6 beta3][Swift] NSDocument addWindowController failing inexplicably
- Subject: Re: [Xcode 6 beta3][Swift] NSDocument addWindowController failing inexplicably
- From: Bavarious <email@hidden>
- Date: Fri, 18 Jul 2014 13:20:30 -0300
On 18 Jul 2014, at 13:10, Philip Shaw <email@hidden> wrote:
> I'm writing a document-based app in Swift, with a custom view controller class, and thus had to implement my own version of makeWindowControllers. However, for some reason the call to self.addWindowControllers does nothing at all. I tried stepping into it in the debugger, but that just stepped over the line.
>
> I'm not sure if the bug is in my code or Apple's - I haven't seen any other users having this problem so I assume it is me.
>
> My document class contains the following (relevant) code:
>
> var additionalWindowController: NSWindowController! /* C */
>
> override func makeWindowControllers() {
> let wc = MessageReadingViewController(windowNibName: "MessageReadingViewController")
> wc.document = self
> NSLog("have %d windowControllers", self.windowControllers.count) /* A */
> self.addWindowController(wc)
> NSLog("have %d windowControllers", self.windowControllers.count) /* A */
> self.additionalWindowController = wc /* C */
> wc.showWindow(self) /* B */
> }
>
> Lines A both print "have 0 windowControllers".
Out of curiosity, what happens if you remove
wc.document = self
from makeWindowControllers()? addWindowController() already sets the window controller document, so you don’t need that statement. Furthermore, addWindowController() removes the window controller from its previous document in case there is one, which may be related to the behaviour you’re seeing.
_______________________________________________
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