• 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: initWithCoder Confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: initWithCoder Confusion


  • Subject: Re: initWithCoder Confusion
  • From: matt neuburg <email@hidden>
  • Date: Tue, 16 Sep 2003 10:37:30 -0700

On Mon, 15 Sep 2003 16:37:02 -0400, Tom Gray <email@hidden> said:
>Hello,
>
>I have a simple document based application. My NSDocument subclass
>seems to be instantiating two different objects when it comes into
>existence following opening of a file. I use O'Reilly's Building Cocoa
>Applications "MathDocument" sample code as my sample code.
>As in their sample, my NSDocument subclass has an init and an
>initWithCoder method

If that's what their sample does, then ignore it. Your NSDocument subclass comes into existence all by itself and is not itself encoded, so all it needs is an init method. At that point it should set up any needed data structure to represent an empty document. When the user opens an existing document, loadDataRepresentation:ofType: is called with the data. Your job is to replace your "empty" data with the data from the file. If this involves decoding the data, go ahead and decode it, but this has nothing to do with how NSDocument itself was originally initialized. m.

--------
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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.

  • Prev by Date: Re: Using NSArchiver with NSDocument - encode the data
  • Next by Date: Re: Using NSArchiver with NSDocument
  • Previous by thread: initWithCoder Confusion
  • Next by thread: AppleScript to make different document types
  • Index(es):
    • Date
    • Thread