Accessor Madness
Accessor Madness
- Subject: Accessor Madness
- From: Kirk Kerekes <email@hidden>
- Date: Fri, 24 May 2002 13:24:29 -0500
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...
_______________________________________________
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.