Re: NSDocument -init vs. -initWithContentsOfFile:ofType: (re post)
Re: NSDocument -init vs. -initWithContentsOfFile:ofType: (re post)
- Subject: Re: NSDocument -init vs. -initWithContentsOfFile:ofType: (re post)
- From: Keith Renz <email@hidden>
- Date: Sun, 7 Sep 2003 21:19:09 -0400
Tom,
Thanks for the reply. It looks like a clean solution except nowhere is
super's implementation of -initWithContentsOfFile:ofType: invoked and
the docs specifically say to do this for NSDocument subclasses. Of
course, the same paragraph implies separation of inits, too, which is
not the case.
Thanks again,
Keith
-----
On Sunday, September 7, 2003, at 08:56 PM, Tom Harrington wrote:
On Sunday, September 7, 2003, at 05:01 PM, Keith Renz wrote:
In my NSDocument subclass, I would like to have separate
initializations for new (untitled) documents and documents opened
from file, i.e. mutually exclusive inits. What I want to do is not
perform a new document's initialization when opening from a file.
[snip...]
I feel like I'm missing something. Can someone shed some light on
this?
In a similar situation I used this approach:
1. Implemented -init, but all it does is this:
return [self initWithContentsOfFile:nil ofType:nil];
2. Implemented -initWithContentsOfFile: ofType more or less as follows:
self = [super init];
if (self) {
if (filename == nil) {
// Do new-doc initialization
} else {
// Do existing-doc initialization using filename argument
}
// Finally do common stuff.
}
return self;
--
Tom Harrington
email@hidden
_______________________________________________
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.