Re: Creating an NSInvocation from an NSMethodSignature

2009-05-13 Thread Mike Mangino
On May 12, 2009, at 6:19 PM, Greg Parker wrote: On May 12, 2009, at 6:43 AM, Michael Ash wrote: Use -methodForSelector: to get the IMP for a nonexistent method. This IMP will be a function pointer straight to the runtime's forwarding machinery. Then install that IMP as the implementation for

Re: Creating an NSInvocation from an NSMethodSignature

2009-05-13 Thread Marcel Weiher
On May 13, 2009, at 11:27 , Mike Mangino wrote: I'm noticing something related that is causing my problems. I have mocking working for custom types. When I try to change the class of a string, however, I get a crash. -(void) testImplementationOnString { NSString *s = [NSString

Re: Creating an NSInvocation from an NSMethodSignature

2009-05-12 Thread Mike Mangino
On May 12, 2009, at 12:58 AM, Michael Ash wrote: [snip] My suggestion would be, if at all possible, avoid creating the NSInvocation manually at all. By far the nicest way to create an invocation is by capturing it using the -forwardInvocation: method. That way you create it using the same

Re: Creating an NSInvocation from an NSMethodSignature

2009-05-12 Thread Mike Mangino
On May 12, 2009, at 9:43 AM, Michael Ash wrote: [snip] This is actually surprisingly easy. (Caveat: I have not actually done this.) Use -methodForSelector: to get the IMP for a nonexistent method. This IMP will be a function pointer straight to the runtime's forwarding machinery. Then

Re: Creating an NSInvocation from an NSMethodSignature

2009-05-12 Thread Michael Ash
On Tue, May 12, 2009 at 11:13 AM, Mike Mangino mmang...@elevatedrails.com wrote: On May 12, 2009, at 9:43 AM, Michael Ash wrote: [snip] This is actually surprisingly easy. (Caveat: I have not actually done this.) Use -methodForSelector: to get the IMP for a nonexistent method. This IMP

Re: Creating an NSInvocation from an NSMethodSignature

2009-05-12 Thread Greg Parker
On May 12, 2009, at 6:43 AM, Michael Ash wrote: Use -methodForSelector: to get the IMP for a nonexistent method. This IMP will be a function pointer straight to the runtime's forwarding machinery. Then install that IMP as the implementation for your overridden methods. Callers will go straight

Re: Creating an NSInvocation from an NSMethodSignature

2009-05-12 Thread Michael Ash
On Tue, May 12, 2009 at 6:19 PM, Greg Parker gpar...@apple.com wrote: On May 12, 2009, at 6:43 AM, Michael Ash wrote: Use -methodForSelector: to get the IMP for a nonexistent method. This IMP will be a function pointer straight to the runtime's forwarding machinery. Then install that IMP as

Re: Creating an NSInvocation from an NSMethodSignature

2009-05-11 Thread Michael Ash
On Mon, May 11, 2009 at 9:04 AM, Mike Mangino mmang...@elevatedrails.com wrote: I'm working on some changes to the OCMock framework to better support partial mocks and I'm a little stuck. In short, I'm trying to write a single method that I can attach to a class. I'm trying to make that method