• 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: 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.

  • Follow-Ups:
    • Re: NSDocument -init vs. -initWithContentsOfFile:ofType: (re post)
      • From: Keith Renz <email@hidden>
References: 
 >NSDocument -init vs. -initWithContentsOfFile:ofType: (re post) (From: Keith Renz <email@hidden>)

  • Prev by Date: Re: Can Pure Java and Cocoa Java get along???
  • Next by Date: Re: AGRegex Memory Hog Bug
  • Previous by thread: NSDocument -init vs. -initWithContentsOfFile:ofType: (re post)
  • Next by thread: Re: NSDocument -init vs. -initWithContentsOfFile:ofType: (re post)
  • Index(es):
    • Date
    • Thread