• 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: Grief with NSDocument windowControllerDidLoadNib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grief with NSDocument windowControllerDidLoadNib


  • Subject: Re: Grief with NSDocument windowControllerDidLoadNib
  • From: Ken Tabb <email@hidden>
  • Date: Thu, 28 Mar 2002 14:08:03 +0000

On Wednesday, March 27, 2002, at 08:07 pm, Brian Webster wrote:

On Wednesday, March 27, 2002, at 12:46 PM, cocoa-dev-
email@hidden wrote:

The problem I have in [5] is that there is a time delay between stages
[2] and [5], so when the document is ready to pass the NSImage over to
the window controller, the window controller hasn't yet loaded the nib
file or hooked anything (including the NSImageView) up. It seems the
document's windowControllerDidLoadNib is the correct place to put the
'delayed' handshaking code, but my document's windowControllerDidLoadNib
isn't getting called. And it's just not fair.

It'd be fair as long as it was clearly documented. Actually, it is documented, it's just not the easiest thing to find. In the "Document Based Applications" programming topic, looking under the FAQ section reveals this:

--------------------------------------------------------------

How can I do extra UI hookup or preparation before or after my nib file loads?


In many applications, you need to perform set up operations right before or after a document's user interface loads.

If you do not subclass NSWindowController then you can override NSDocument's windowControllerWillLoadNib: or windowControllerDidLoadNib: methods to do any extra setup you need to do.

If you do subclass NSWindowController you should instead override NSWindowController's windowWillLoad and windowDidLoad methods.

------------------------------------------------------------------

So, just implement windowDidLoad in your window controller and you should be able to do what you want from there.

Hi Brian,
thanks for the info. I've already tried this, but I still don't see it as the most elegant approach (though I agree with you it's the one they say we should use, and the documentation is certainly lacking in this respect as different pages say different things).

The reason I don't think it's elegant is because the document loads the image and makes an NSImage from it, but there is a break while the window controller subclass loads and sets up the nib. What the above seems to be suggesting is that the window controller then (in its windowDidLoad method) asks the document for the image. This assumes the window controller knows about the document class. I thought the whole point of MVC was that the window controller knew nothing about the document, just how to display things. In other words it shouldn't know where to get the things which need displaying, they should be provided to it. As the document owns the window controller, I would have thought it would make more sense to get the document to give the window controller the NSImage rather than get the window controller to (implicitly know about and) ask the document for the NSImage.

So basically I've already got the app working by the above suggested method, but it seems to break most rules of the MVC design paradigm and results in inelegant and assumptive code.

Or maybe I've had too much fizzy pop to think straight today.

Comments on a set of guitar strings please,
Ken

- - - - - - - - - -
Ken Tabb
Mac & UNIX Technical bloke (C, C++, Obj-C, Java) - Health & Human Sciences
Machine Vision & Neural Network researcher - Computer Science Dept
University of Hertfordshire, UK
http://www.health.herts.ac.uk/ken/

Certified non-Microsoft Solution Provider
_______________________________________________
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: Grief with NSDocument windowControllerDidLoadNib
      • From: Brian Webster <email@hidden>
References: 
 >Re: Grief with NSDocument windowControllerDidLoadNib (From: Brian Webster <email@hidden>)

  • Prev by Date: Re: Simple "SpreadSheet"
  • Next by Date: EOF (was [objC retain];
  • Previous by thread: Re: Grief with NSDocument windowControllerDidLoadNib
  • Next by thread: Re: Grief with NSDocument windowControllerDidLoadNib
  • Index(es):
    • Date
    • Thread