• 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: encodeWithCoder for a BOOL?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: encodeWithCoder for a BOOL?


  • Subject: Re: encodeWithCoder for a BOOL?
  • From: Marcel Weiher <email@hidden>
  • Date: Mon, 8 Apr 2002 09:29:15 +0200

You can try that:

[coder encodeValueOfObjCType:@encode(BOOL) at:&myBool];

Or even:

[coder encodeValueOfObjCType:@encode(typeof(myBool)) at:&myBool];

That way, you don't hard-code the type if you var in a separate place, with all the chances of getting out of sync etc.

In fact, this is essentially what MPWFoundation uses in its convenience encoding-macros:

encodeVar( coder, var )

This will (a) take the address of 'var' (b) figure out the type/encoding of 'var' and (c) also pass the name of 'var' to the encoding routines, to also make it work with name-based encoding schemes (XML...). The existing coders are extended with a category to ignore the name.

Call me lazy...

Marcel


--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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.

References: 
 >Re: encodeWithCoder for a BOOL? (From: Raphael Sebbe <email@hidden>)

  • Prev by Date: Scripting, OSA style
  • Next by Date: Closing Drawers
  • Previous by thread: Re: encodeWithCoder for a BOOL?
  • Next by thread: Operator overloading (was: Re: Several questions on Objective C)
  • Index(es):
    • Date
    • Thread