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: Tom Harrington <email@hidden>
- Date: Sun, 7 Sep 2003 18:56:37 -0600
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.