• 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 08:50:50 -0400


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 syntax you use to send any other message, and the runtime takes care of all the icky details like argument sizes.

I would love to do that. I'm trying to allow partial mocking of internal objects. The current code creates a partial mock as a proxy, which makes getting the invocation really easy. Unfortunately, it means you can't mock a method that is called inside the object.


To work around this, I'm dynamically creating a subclass which overrides the methods I want to mock. This allows me to mock methods on calls to self. Unfortunately, I no longer get an NSInvocation.

I was looking at removing all of the methods on the parent and handling them all with my own dispatch, but removing methods seems to be deprecated in 2.0. Can anyone think of another way to get an invocation?

If not, I'll just build the table and parse things myself. I'll definitely skip structs.

Mike



Mike

-- 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>)

  • Prev by Date: Re: Drawing 1 pixel line with zoom change
  • Next by Date: Re: NSString and retain.
  • Previous by thread: Re: Creating an NSInvocation from an NSMethodSignature
  • Next by thread: Re: Creating an NSInvocation from an NSMethodSignature
  • Index(es):
    • Date
    • Thread