• 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 -init vs. -initWithContentsOfFile:ofType: (re post)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: NSDocument -init vs. -initWithContentsOfFile:ofType: (re post) (From: Tom Harrington <email@hidden>)

  • Prev by Date: Re: AGRegex Memory Hog Bug
  • Next by Date: Re: AGRegex Memory Hog Bug
  • Previous by thread: Re: NSDocument -init vs. -initWithContentsOfFile:ofType: (re post)
  • Next by thread: Does anyone have sample code for writing/updating multi-valued properties to the address book?
  • Index(es):
    • Date
    • Thread