Re: NSArchiver question
Re: NSArchiver question
- Subject: Re: NSArchiver question
- From: Marcel Weiher <email@hidden>
- Date: Mon, 25 Apr 2005 13:41:49 +0100
On 24 Apr 2005, at 23:49, Will Mason wrote:
However, it seems NSArchiver does not have methods for archiving
basic
C types (for example, there is encodeInt:forKey but there is no
encodeInt:). So what is the proper way to encode the primitive C
types
with NSArchiver? Is it the encodeBytes:length: method? Or maybe I
have missed something obvious?
You can just use encodeValueOfObjCType:at:, like this:
// archiver is an instance of NSArchiver
int value = 12;
[archiver encodeValueOfObjCType: @encode(int) at: &value];
And if that seems a little arduous, you might just MPWFoundation's
encoding macros, which shorten this to the following:
encodeVar( archiver , value );
This will expand to the code above and will also work with the XML
archivers found in Objective-XML.
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
1d480c25f397c4786386135f8e8938e4
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden