Re: NSDocument's loadDataRepresentation called before the document UI is functional?
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.