On 18 Jul 2014, at 13:10, Philip Shaw <[email protected]> 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 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]

Reply via email to