• 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: Glen Low <email@hidden>
  • Date: Tue, 22 Jun 2004 07:44:22 +0800

On 20/06/2004, at 12:54 AM, Izidor Jerebic wrote:


On 18 Jun 2004, at 16:59, Glen Low wrote:

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.


2. Assuming I make my NSWindowController subclass and wire it into the system, does the NSWindowController then pass responder chain messages back up to the NSDocument (or subclass) or do I have to handle all the messages at the NSWindowController level e.g. save?



No need to change anything. Messages such as "Save" will be handled by appropriate object (NSDocument) just fine...


Yes it appears that after NSWindow looks at an event (and also consults its delegate), it passes it to NSWindowController, which eventually consults the document, so the responder chain is working as expected.

Since I don't really need to change NSWindowController functionality, and following the doctrine of "aggregation is better than inheritance 80% of the time", I didn't subclass NSWindowController but just made a subclass of NSObject to serve as the window delegate. Everything's hunky-dory now.

Cheers, Glen Low


---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
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.


  • Follow-Ups:
    • Re: Where's the NSWindowController in a default document-based app [SOLVED]
      • From: Mike Ferris <email@hidden>
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>)

  • Prev by Date: Cmd+ to be same as cmd=
  • Next by Date: Re: Is that really a bug at all? (was: Re: Ugly bug in Foundation, beware!)
  • Previous by thread: Re: Where's the NSWindowController in a default document-based app
  • Next by thread: Re: Where's the NSWindowController in a default document-based app [SOLVED]
  • Index(es):
    • Date
    • Thread