Hi there,

this is more a style question than anything else, but I'm sometimes 
perfectionist. ;) I am also aware it is somewhat borderline with Cocoa (belongs 
more to ObjC in general); sorry for this.

I have designed a kind of a fake class which is, in reality, a simple 
collection of algorithms implemented as class methods. They all take the same 
three arguments, however. The user can pick up an algorithm by selecting a 
conventional name in a popup button. Then the code is supposed to call the 
selected class method, whose selector is known through a simple dictionary 
lookup.

I supposed I couldn't do such a simple thing as [MyClass perform:selector] 
because the perform: method is an instance one. So I wrote this:

Method  theAlgorithmMethod = class_getClassMethod ([MyClass class], 
theAlgorithm);
IMP     itsImplementation = method_getImplementation (theAlgorithmMethod);
result = (* itsImplementation)(self, algorithm, …)

which works fine. But is there a clever way to achieve this?

Thanks a lot,
Vincent_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to