Re: Performing the selector from a stored IMP

2011-02-11 Thread Bill Bumgarner
On Feb 11, 2011, at 1:16 PM, Joanna Carter wrote: > I would totally agree that it is a phenomenally powerful concept, giving just > the kind of functionality I was originally looking for, as a replacement for > method pointers. I will be using it as soon as I find a need that warrants it. > >

Re: Performing the selector from a stored IMP

2011-02-11 Thread Joanna Carter
Hi Matt > But consider NSUndoManager. What its +prepareWithInvocationTarget:+ does is > almost exactly what you describe: you give it a target and send it a method > call, a method call that NSUndoManager itself cannot respond to. Instead of > complaining, it freeze-dries that method call and i

Re: Performing the selector from a stored IMP

2011-02-11 Thread Matt Neuburg
On Feb 11, 2011, at 12:20 PM, Joanna Carter wrote: > >> Consider NSInvocation... m. > > Hmmm, nice! > > My only objection to using it in the circumstances I have is that it is a lot > more code to setup But consider NSUndoManager. What its +prepareWithInvocationTarget:+ does is almost exact

Re: Performing the selector from a stored IMP

2011-02-11 Thread Tito Ciuro
Hello, Being curious about the performance implications of using NSInvocation vs Objective-C message send vs IMP-cached message send, I was surprised to see how much slower NSInvocation seems to be compared to the other two mechanisms (the following data was last collected on Leopard, so these

Re: Performing the selector from a stored IMP

2011-02-11 Thread Joanna Carter
Hi Matt > Consider NSInvocation... m. Hmmm, nice! My only objection to using it in the circumstances I have is that it is a lot more code to setup than the idea of a protocol with three methods, implemented by the target class. However, I am indebted to you for pointing out this class and sha

Re: Performing the selector from a stored IMP

2011-02-11 Thread Matt Neuburg
> Date: Fri, 11 Feb 2011 12:21:29 + > From: Joanna Carter > Subject: Performing the selector from a stored IMP > > I want to store a "method pointer" in a dictionary, recover it and call it > from elsewhere in code. > Consider NSInvocation... m. -- matt neuburg, phd = m...@tidbits.com, h

Re: Performing the selector from a stored IMP

2011-02-11 Thread Jean-Daniel Dupas
Le 11 févr. 2011 à 14:31, Joanna Carter a écrit : > 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

Re: Performing the selector from a stored IMP

2011-02-11 Thread Joanna Carter
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(), t

Re: Performing the selector from a stored IMP

2011-02-11 Thread Jean-Daniel Dupas
Le 11 févr. 2011 à 13:21, Joanna Carter a écrit : > 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( myMeth

Re: Performing the selector from a stored IMP

2011-02-11 Thread Jerry Krinock
On 2011 Feb 11, at 04:21, Joanna Carter wrote: > IMP anIMP = [anObject methodForSelector:@selector( myMethod: )]; > [myDictionary setObject:anIMP forKey:myKey]; The compiler should warn you on that second line that an IMP is not an object. This code won't work. > Or have I misunderstood wha