• 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: Creating an NSInvocation from an NSMethodSignature
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating an NSInvocation from an NSMethodSignature


  • Subject: Re: Creating an NSInvocation from an NSMethodSignature
  • From: Mike Mangino <email@hidden>
  • Date: Tue, 12 May 2009 11:13:01 -0400


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 install that IMP as the implementation for your
overridden methods. Callers will go straight into the forwarding
machinery rather than into your overridden methods, which will then
invoke -forwardInvocation: as usual and you can then do as you like.

Since I haven't ever tried this, I'd be very interested to know how it
works for you if you try it.

Brilliant! It works perfectly. Now I just need to wire up a bunch of plumbing and I'll have a patch that handles actual partial mocks.


Mike



Mike
_______________________________________________

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

-- Mike Mangino http://www.elevatedrails.com



_______________________________________________

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: Creating an NSInvocation from an NSMethodSignature
      • From: Michael Ash <email@hidden>
References: 
 >Creating an NSInvocation from an NSMethodSignature (From: Mike Mangino <email@hidden>)
 >Re: Creating an NSInvocation from an NSMethodSignature (From: Michael Ash <email@hidden>)
 >Re: Creating an NSInvocation from an NSMethodSignature (From: Mike Mangino <email@hidden>)
 >Re: Creating an NSInvocation from an NSMethodSignature (From: Michael Ash <email@hidden>)

  • Prev by Date: Re: NSTimer with userInfo
  • Next by Date: Re: how to enable by-default the dock menu "open at login" option
  • Previous by thread: Re: Creating an NSInvocation from an NSMethodSignature
  • Next by thread: Re: Creating an NSInvocation from an NSMethodSignature
  • Index(es):
    • Date
    • Thread