• 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
Re: Where's the NSWindowController in a default document-based app [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where's the NSWindowController in a default document-based app [SOLVED]


  • Subject: Re: Where's the NSWindowController in a default document-based app [SOLVED]
  • From: Mike Ferris <email@hidden>
  • Date: Wed, 23 Jun 2004 08:07:32 -0700

Hi All,

However what I don't quite understand is this:

1. When I make a new document-based app in Xcode, by default the nib gets set like this:

File's Owner == NSDocument
File's Owner window outlet == window
window's delegate == File Owner

So where does the (default?) NSWindowController come into play?


In simple default single-window-document app, the NSDocument plays the role of window controller, so there is no NSWindowController.

There actually is a NSWindowController, you can see it by doing [document windowControllers]. It also is the next responder of the NSWindow, which I didn't know before (and doesn't seem well documented). There must be some kind of magic happening underneath the covers too, because in the single-window doc app, the File Owner has a "window" outlet but NSDocument has no window outlet, only NSWindowController has that outlet.


NSDocument does have a conceptual window outlet (it's setWindow: method and _window instance variable). One of the main reasons that NSDocument uses NSWindowController behind the scenes is because it wants to let NSWindowController manage the life cycle of the top-level nib objects. One of the fairly magical properties of NSWindowController (magical in that it is hard to achieve via other means) is that it automatically knows about the top-level objects in the nib file it loads and will release them all when it deallocates. Without this mechanism folks used to have to make sure they had outlets to all the top-level nib objects and manually release them when appropriate. But NSWindowController makes this automatic. NSDocument gets that life-cycle management by using an NSWindowController to load and own the nib.

Mike
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Where's the NSWindowController in a default document-based app (From: Glen Low <email@hidden>)
 >Re: Where's the NSWindowController in a default document-based app (From: Izidor Jerebic <email@hidden>)
 >Re: Where's the NSWindowController in a default document-based app [SOLVED] (From: Glen Low <email@hidden>)

  • Prev by Date: Re: Attaching file types & icons to app
  • Next by Date: Controller layer & document architecture
  • Previous by thread: Re: Where's the NSWindowController in a default document-based app [SOLVED]
  • Next by thread: Coalescing undos because of bindings
  • Index(es):
    • Date
    • Thread