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 6675505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:51:53+00:00 2026-05-26T03:51:53+00:00

From the Apple Objective-C documentation, bolded relevant parts: Method Return and Parameter Types The

  • 0

From the Apple Objective-C documentation, bolded relevant parts:

Method Return and Parameter Types

The messaging routine has access to method implementations only
through selectors, so it treats all methods with the same selector
alike. It discovers the return type of a method, and the data types of
its parameters, from the selector. Therefore, except for messages sent
to statically typed receivers, dynamic binding requires all
implementations of identically named methods to have the same return
type and the same parameter types.
(Statically typed receivers are an
exception to this rule because the compiler can learn about the method
implementation from the class type.)

Although identically named class methods and instance methods are
represented by the same selector, they can have different parameter
types and return types.

I’ve read this block over and over but I can’t seem to get past what seems to be a contradiction. First it says that all implementations of identically named methods are required to have the same return type and parameter types because of dynamic binding.

Since it treats all methods with the same selector alike, does this mean that no matter how many different objects I have, if they all have a EatCake() method then they will all share the same selector for EatCake? If so, then why must they have the same parameters and return type?

Then in the next part it says though they are represented by the same selector, they can have different parameter types and return types. So now I’m totally confused, I thought it just said this was not the case.

I do not expect that this is a mistake, I expect that I am simply not understanding what the difference is between these two statements.

Can anyone clear this up for me?

  • 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-05-26T03:51:53+00:00Added an answer on May 26, 2026 at 3:51 am

    It is not required that all methods with the same selector have the same parameter and return types. The selector is simply a name which identifies the method, without any of that information attached.

    The problem is that the compiler has to know what the parameter and return types are when you call a method so that it can perform type checking for you. When the excerpt talks about dynamic receivers, it is talking about variables with a type of id and messages sent to the result of a method which returns id. Since this only tells the compiler that it is an object, but not what class it is, it cannot determine which class should be used to determine the parameter and return types. Therefore, the only way it can know is if all uses of that selector have the same parameter and return types.

    The excerpt also explains that the exception is for statically typed receivers, which means you specified a certain class for your variable type, such as NSString *myString. Since the compiler knows that the object must be an NSString object, it knows to use the parameter and return types from that class, so it doesn’t need to be the same for objects of a different class.

    This all has absolutely no effect on the runtime. When you call a method, the runtime gets that objects actual class and uses that to find the proper implementation to call. It performs no type checking, so it doesn’t care what the parameter and return types are.

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

Sidebar

Related Questions

In the BubbleLevel example from apple they implement an +initialize method. They say: +initialize
From the Apple documentation on animating property changes in a view, In order to
As a Java developer who is reading Apple's Objective-C 2.0 documentation: I wonder what
Objective C docs from apple says For the object-oriented constructs of Objective-C, such as
I know Objective-C from Desktop Apple Programming. But i want to jump on the
I was reading Apple's documentation, The Objective-C Programming Language (PDF link). On pg. 18,
Strange situation - examples from apple works, but after i change them a bit,
This is unmodified code from Apple's iPhone 'Utility Aplication' template: - (void)applicationDidFinishLaunching:(UIApplication *)application {
I noticed by looking at sample code from Apple, that they tend to design
Can i run download applications from Apple Store on iPhone simulator?

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.