Re: encodeWithCoder for a BOOL?
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.