Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8473613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:23:58+00:00 2026-06-10T17:23:58+00:00

Going through Apache Cordova’s source code, I ran into two lines of code that

  • 0

Going through Apache Cordova’s source code, I ran into two lines of code that I’m puzzled about:

    //[obj performSelector:normalSelector withObject:command];
    objc_msgSend(obj,normalSelector,command);

From Apple’s documentation, there doesn’t seem to be a lot of difference between these two methods.

id objc_msgSend(id theReceiver, SEL theSelector, …)
Sends a message with a simple return value to an instance of a class.

– (id)performSelector:(SEL)aSelectorwithObject:(id)anObject
Sends a message to the receiver with an object as the argument. (required)

What exactly is the difference between these two methods? In the case above, both are sending messages with an object as an argument to a receiving object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:23:59+00:00Added an answer on June 10, 2026 at 5:23 pm

    You’re asking the difference between two “methods” but only one of them is actually a method. The objc_msgSend function is, well, a function. Not a method.

    The objc_msgSend function is the function that you actually call when you invoke any method on any object in Objective C. For example, the following two are basically equivalent:

    // This is what the compiler generates
    objc_msgSend(obj, @selector(sel:), param);
    
    // This is what you write
    [obj sel:param];
    
    // You can check the assembly output, they are *almost* identical!
    

    The major difference here is that objc_msgSend does not get type checked by the compiler — or at least, its arguments don’t get type checked against the selector’s parameter types. So the following are roughly equivalent:

    [obj performSelector:normalSelector withObject:command];
    objc_msgSend(obj, @selector(performSelector:withObject:),
                 normalSelector, command);
    

    But, that’s a bit of a waste, since all performSelector:withObject: does is call objc_msgSend.

    HOWEVER: You should stay away from obc_msgSend because it is not type-safe, as mentioned above. All the apache devs are doing is removing a single method call, which will only give you very slight performance benefits in most cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been going through two tutorials to get the code for this project of
I am going through the Tapestry beginner tutorial at: http://tapestry.apache.org/tapestry-tutorial.html I just downloaded the
Going through happstack-lite tutorial : we build functions that have return type of ServerPart
Going through Javascript documentation, I found the following two functions on a Javascript object
While going through SWig generated wrappers, I find that the PInvokes don't have any
While going through some tutorials, I have encountered lines such as this: ((IDisposable)foo).Dispose(); Ignore
Just going through the sample Scala code on Scala website, but encountered an annoying
I am going through apache cassandra and working on sample data insertion, retrieving etc.
I have an SVN repository that is configured to use Basic authentication through Apache
I was going through a book that explain how to override 'default' lifecycle of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.