Performing the selector from a stored IMP
Performing the selector from a stored IMP
- Subject: Performing the selector from a stored IMP
- From: Joanna Carter <email@hidden>
- Date: Fri, 11 Feb 2011 12:21:29 +0000
Hi folks
I want to store a "method pointer" in a dictionary, recover it and call it from elsewhere in code.
So, I have code like this to store the "method pointer":
{
IMP anIMP = [anObject methodForSelector:@selector( myMethod: )];
[myDictionary setObject:anIMP forKey:myKey];
}
… and then, elsewhere, I want to recover the IMP from the dictionary and invoke the selector on the "self" object that is held in the IMP.
Or have I misunderstood what IMPs do?
In C#, a delegate knows about the "this", upon which the method will be called, within itself and can simply be called without having to go through any gymnastics to get the target object. Isn't this what IMPs do?
TIA
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden