Re: Document opening question
Re: Document opening question
- Subject: Re: Document opening question
- From: "Louis C. Sacha" <email@hidden>
- Date: Tue, 25 Nov 2003 15:38:03 -0800
Hello...
Is the document displayed with the windows actually appearing on
screen, or are you seeing this behavior while watching/logging as
part of debugging?
As far as I know, if you return NO for loadDataRepresentation:ofType:
it will cause the document to fail to open, calling dealloc and
returning nil from it's initializatiion, eventually resulting in an
alert for the user from the NSDocumentController (at least as of
10.2).
You might want to check and make sure that if you've partially
overridden any of the other file reading methods that the results are
passed along properly, and also check if you've overriden the
initWithContentsOf...:ofType: methods correctly. Sometimes it's
helpful to override these functions if you aren't already with simple
versions that use NSLog to log what function is starting, call the
superclass version, and then NSLog that the function is ending (with
some indication of the result) just to verify that everything is
being passed on correctly (and that your methods are returning the
values that you intend).
Also, just in case you are, you shouldn't call NSDocument's default
implementation of loadDataRepresentation:ofType: since it is
intended to be completely overriden by the subclass version (although
I don't think it would do anything, except possibly return TRUE or
FALSE, but I've never actually checked).
Louis
My NSDocument subclass overrides -loadDataRepresentation:ofType: to
read in its XML-based documents. If, in reading the document, it
detects something wrong in the file (the file is corrupt, or has
URLs to things that don't exist, or something like that),
-loadDataRepresentation:ofType: returns NO. However, it appears that
the superclass still goes ahead and loads the document nib, and
creates the document windows, etc.
I've found that if I raise an exception that I don't handle in
-loadDataRepresentation:ofType:, then the superclass doesn't create
any of the windows. Is this the proper way to tell the superclass
(or the application) that reading the data failed and not to create
the windows? Will this properly clean up the document that got
half-way created during reading of the file?
Thanks,
Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
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.
_______________________________________________
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.