Re: Performing the selector from a stored IMP
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