• 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
swift: windowControllerDidLoadNib called twice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

swift: windowControllerDidLoadNib called twice


  • Subject: swift: windowControllerDidLoadNib called twice
  • From: Boyd Collier <email@hidden>
  • Date: Fri, 18 Sep 2015 16:40:44 -0700

I have a simple OS X project ( in swift 2.0 and Xcode 7.0) and  that is supposed to open a .txt file and display the file’s contents in a document window.  For the most part, it works correctly, except that windowControllerDidLoadNib is called twice each time I chose OpenFile from the file menu.  This results in the contents of the file being displayed in my document window twice in succession.  The code is very similar to an objective-c project, which doesn’t do this, and I can’t see why this is happening.  Here’s an abbreviated version of windowControllerDidLoadNib:

override func windowControllerDidLoadNib(mySharedDocumentController: NSWindowController) {
        let myTextView: NSTextView = (self.TextView) as NSTextView

        let theWindow: NSWindow = myTextView.window! // NSTextView inherits from NSView, which can return a window

        // the next 2 lines are simply to test getting the name of the window; this is done correctly
        let theName: NSString? = theWindow.title
        print(“now at the top of windowControllerDidLoadNib \(theName)")

        scrollview.documentView = myTextView
        theWindow.contentView = scrollview

        theWindow.makeKeyAndOrderFront(nil)

        theWindow.makeFirstResponder(TextView)

        print("\n we are at the end of windowControllerDidLoadNib")

	updateView()  // the code of updateView has nothing to do with the problem; when it’s commented out, “now at the top of windowControllerDidLoadNib” still gets show twice

    }

Any suggestions why this might be happening would be greatly appreciated.

Boyd
_______________________________________________

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: swift: windowControllerDidLoadNib called twice
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: [OT] VPN Problems?
  • Next by Date: Re: Working with NSTextFields
  • Previous by thread: Re: [OT] VPN Problems?
  • Next by thread: Re: swift: windowControllerDidLoadNib called twice
  • Index(es):
    • Date
    • Thread