Re: initWithCoder Confusion
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.