On Jul 11, 2012, at 7:03 AM, Dave DeLong <[email protected]> wrote: > You'll have to override +resolveInstanceMethod: to figure out what the user > is trying to do: get or set. You'll use the selector passed in to derive the > key under which you're storing the data in the dictionary. With this > information, you construct a block of the appropriate signature, capturing > whatever information you need, and turn it into an IMP using > imp_implementationWithBlock(). You can then add that method to the class > using class_addMethod().
I implemented this as part of the CouchCocoa library (and yes, it is pretty tricky). I tried to factor it so the base class is generic, and should be exactly what the OP is looking for: https://github.com/couchbaselabs/CouchCocoa/blob/master/Model/CouchDynamicObject.h https://github.com/couchbaselabs/CouchCocoa/blob/master/Model/CouchDynamicObject.m —Jens _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
