• 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
Re: Performing the selector from a stored IMP
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performing the selector from a stored IMP


  • Subject: Re: Performing the selector from a stored IMP
  • From: Joanna Carter <email@hidden>
  • Date: Fri, 11 Feb 2011 13:31:27 +0000

Hi Jerry

> You've misunderstood what an IMP *is*.

Heheheh, I thought as much :-)

> If you want to store a method, you could probably wrap that the pointer value of an IMP as an NSValue.  Read NSValue.  Or, for persistent storage, store the method name you get from NSStringFromSelector(), then retrieve it with NSSelectorFromString().  Use the latter technique sparingly because the compiler cannot warn you about undefined methods, etc. - think JavaScript.

(Fortunately, I don't know anything much about JavaScript, so hopefully that's less confusing)

Anyway, from what you are saying, it would appear that NSSelectorFromString() would still need the target object in order to perform the selector, so that is just as useless :-)

Whilst waiting for replies I have been busy rationalising things out and have come to the solution of declaring a MyDelegates protocol with the three delegate methods on it, implementing the protocol on the class, upon which I want to call the methods, and storing id<MyDelegates> references in the dictionary.

This ensures that only a valid object, which implements the three delegates can be added to my static dictionary wrapper class and that that the wrapper class returns a valid (typesafe) instance with the three delegates available.

I really am going to have to do some more reading to find out if and when I might want to use an IMP.

Thank you

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>
References: 
 >Performing the selector from a stored IMP (From: Joanna Carter <email@hidden>)
 >Re: Performing the selector from a stored IMP (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Performing the selector from a stored IMP
  • Next by Date: Re: Performing the selector from a stored IMP
  • Previous by thread: Re: Performing the selector from a stored IMP
  • Next by thread: Re: Performing the selector from a stored IMP
  • Index(es):
    • Date
    • Thread