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

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
References: 
 >Re: NSArchiver question (From: Will Mason <email@hidden>)

  • Prev by Date: Re: Calling original method implementation from category
  • Next by Date: Re: Calling original method implementation from category
  • Previous by thread: Re: NSArchiver question
  • Next by thread: Need a little help with KVC Array operators
  • Index(es):
    • Date
    • Thread