• 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: NSDocument's loadDataRepresentation called before the document UI is functional?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocument's loadDataRepresentation called before the document UI is functional?


  • Subject: Re: NSDocument's loadDataRepresentation called before the document UI is functional?
  • From: Scott Anguish <email@hidden>
  • Date: Tue, 12 Aug 2003 18:10:41 -0400

On Monday, August 11, 2003, at 9:05 PM, Wade Tregaskis wrote:

Simply put, any UI-related code in loadDataRepresentation doesn't have any effect - text views which have their text storage updated don't reflect the change, tables won't change selected rows, etc etc.

How can I fix/get around this?

-loadDataRepresentation is called before -windowControllerDidLoadNib. The idea is that in -loadDataRepresentation, you should only deal with the model, not the view or controller. When -windowControllerDidLoadNib is called, the model should already be in place.

The workaround, for anyone interested, is to store the data you receive in loadDataRepresentation, and only use that data in windowControllerDidLoadNib.

The problem with this is that it's a pain in the butt, and not documented either.


http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/ index.html

In the "Implementing a Document Based Application" article it has an example of doing this in Step 8

I've filed a bug requesting that this be added to the FAQ for that topic.

BTW.. this is discussed in the HTMLEditor articles on Stepwise, and I think in the Cocoa Programming book as well.


If I want to set the contents of a few text fields, I shouldn't need to mirror their contents in my model implementation.


You don't need to. You can temporarily store those values in the controller.

You don't want to have to load and create the UI (a potentially expensive operation) and then have to tear it all down if the load fails.

You load the data, and then you create/populate the UI if it loaded successfully.
_______________________________________________
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: 
 >Re: NSDocument's loadDataRepresentation called before the document UI is functional? (From: Wade Tregaskis <email@hidden>)

  • Prev by Date: RE: Managing Retain/Release for a ContentView
  • Next by Date: Re: Uninstaller Howto?
  • Previous by thread: Re: NSDocument's loadDataRepresentation called before the document UI is functional?
  • Next by thread: Question about poseAsClass
  • Index(es):
    • Date
    • Thread