Re: Accessor Madness
Re: Accessor Madness
- Subject: Re: Accessor Madness
- From: Marcel Weiher <email@hidden>
- Date: Fri, 24 May 2002 20:45:50 +0200
MPWFoundation has a bunch of accessor macros that do the whole thing:
idAccessor( var, setVar )
will expand into both the 'get' and 'set' accessors. MPWFoundation also
has macros for encoding/decoding, along with HOM and filter-streams and
all that other stuff...
Marcel
On Friday, May 24, 2002, at 08:24 Uhr, Kirk Kerekes wrote:
While waiting for the Perfect Accessor Generator (which ought to be
integral to PB -- hint, hint, Apple), I am using the following:
A vanilla C macro:
#define SETIDACCESSOR(obj,iv) [self KKSetObject:(obj) inIV:
&(iv)
]
Combined with a method:
- (void) KKSetObject:(id) object inIV:(id *) iv
{
id temp = *iv;
[object retain];
*iv = object;
[temp release];
}
-- so that my object-set-accessors are reduced to:
- (void) setModelData:(NSDictionary *) dict
{
SETIDACCESSOR(dict,modelData);
}
Someone with more desire to mess with #defines than I do could probably
reduce this to:
SETIDACCESSOR(modelData);
-- although I'm not going to try unless someone can tell me how to see
preprocessor output in PB.
Now if only I would declare KKSetObject:inIV: as a category on
NSObject...
--
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.