Re: Using NSArchiver with NSDocument
Re: Using NSArchiver with NSDocument
- Subject: Re: Using NSArchiver with NSDocument
- From: matt neuburg <email@hidden>
- Date: Tue, 16 Sep 2003 10:47:49 -0700
On Mon, 15 Sep 2003 21:29:16 -0400, Weeks Family <email@hidden> said:
>
I am creating an application using the the Cocoa multi-document
>
architecture. When I save my document (subclass of NSDocument) the
>
encodeWithCoder method gets called twice. The saved document opens
>
okay. I am concerned that the saved file is unnecessarily large and
>
that I really do have a problem but just don't know it yet.
>
>
You can reproduce this by creating a new Cocoa document-based
>
application project in Project Builder V2.1. Add this empty method to
>
MyDocument:
>
- (void)encodeWithCoder:(NSCoder *)coder
>
{
>
}
>
Replace the return line in this method:
>
- (NSData *)dataRepresentationOfType:(NSString *)aType
>
{
>
return [NSArchiver archivedDataWithRootObject:self];
>
}
No, thanks, I'd rather not. This is exactly the same question I just answered a couple of moments ago ("initWithCode confusion"). An NSDocument is a controller; it handles things like the opening and closing of the document's data and the management of its windows. It is not the document's data (the model). It isn't the NSDocument you want to encode when you save the document; it's the data. 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.