• 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: NSInvocation question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSInvocation question


  • Subject: Re: NSInvocation question
  • From: Hank Heijink <email@hidden>
  • Date: Fri, 22 Feb 2008 10:36:36 -0500

On Feb 21, 2008, at 11:18 PM, Chris Suter wrote:

I'm not sure what exactly you're trying to do, but NSInvocation isn't that fast a way of making a call. It's certainly going to somewhat slower than a compiler generated call and it's not NSInvocation's intended use.

I should have realized that when NSInvocation started giving me trouble...


If you want fast calls, you should use -[NSObject methodSelector:], cache the result and then call it directly with whatever arguments you want. Make sure you read the documentation to see an example as it usually requires a cast.

Having said that, let me say what has been said many times before, unless you know it's going to be a performance bottleneck, you should be writing your code so that it's as readable/maintainable as possible and then optimise for performance if necessary.

The nice thing about NSInvocation is not so much its efficiency (or lack thereof, as the case may be), but the fact that once you've got the thing constructed, you can just call invoke on it, without having to think about what's inside. I have functions of zero, one, or two arguments that I wrapped up in NSInvocations. With IMPs, I have to check the number of arguments both for the typing and for the call.


However, even with the check for number of arguments, an IMP is very very fast.

Thanks!

Hank

Hank Heijink
email@hidden



_______________________________________________

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: NSInvocation question
      • From: Chris Suter <email@hidden>
References: 
 >NSInvocation question (From: Hank Heijink <email@hidden>)
 >Re: NSInvocation question (From: Nir Soffer <email@hidden>)
 >Re: NSInvocation question (From: Hank Heijink <email@hidden>)
 >Re: NSInvocation question (From: Chris Suter <email@hidden>)

  • Prev by Date: Re: Simple Core Data Binding Question: NSTextField to Integer attribute
  • Next by Date: Re: nsoutlineview crashes
  • Previous by thread: Re: NSInvocation question
  • Next by thread: Re: NSInvocation question
  • Index(es):
    • Date
    • Thread