On 19 Jul 2014, at 1:50 , Bavarious <bavari...@icloud.com> wrote: > On 18 Jul 2014, at 13:10, Philip Shaw <wahspil...@gmail.com> 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.
Thanks, yes, that fixed it. I can’t remember why I added that line, but that documentation of NSWindowController was pretty clear that I shouldn’t have.
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com