• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Performing the selector from a stored IMP
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Performing the selector from a stored IMP
      • From: Jean-Daniel Dupas <email@hidden>
    • Re: Performing the selector from a stored IMP
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: [iOS] Strange behavior of NSFetchedResultsController
  • Next by Date: Re: Performing the selector from a stored IMP
  • Previous by thread: Invitation to connect on LinkedIn
  • Next by thread: Re: Performing the selector from a stored IMP
  • Index(es):
    • Date
    • Thread