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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:07:14+00:00 2026-06-09T00:07:14+00:00

This is a slight follow on from a previous question: for(id <stuffieProtocol> eachObject in

  • 0

This is a slight follow on from a previous question:

for(id <stuffieProtocol> eachObject in stuffieArray) {
    if([eachObject respondsToSelector:@selector(secretID)]) [eachObject secretID];
}

The above is a line from a fast enumeration loop that takes a number of objects out of an NSArray and checks to see if they respond to the method secretID. The method secretID is not part of the @protocol but rather a method defined on one of the objects in the collection.

The if statement above fails because the compiler says "No known instance method for selector secretID" Which is fine, id does not care and the method is not defined in <stuffieProtocol> I can fix this by casting each object to the type that does define secretID:

if([eachObject respondsToSelector:@selector(secretID)]) [(Ted *)eachObject secretID];

My question is in the original code, how does the compiler know that eachObject responds to the method secretID but yet when you ask it to call that method its says “No known method” I am just a little curious about the mechanics?

  • 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-09T00:07:18+00:00Added an answer on June 9, 2026 at 12:07 am

    The compiler doesn’t know anything about whether the object responds to that selector but the runtime does. (i.e. The compiler doesn’t execute the code.) The compiler only cares that any NSObject can respond to respondsToSelector:.

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

Sidebar

Related Questions

This is a slight update to my previous question I have a Python list
This question is kind of a follow up to this question I asked a
This is a follow-up to my question yesterday - Recursive UL LI to PHP
This is related to this question here, but with a slight twist: instead of
This is a common question but I have a slight twist to it so
Similar to this question: C# Constructor Design but this question is slight different. I
This is a slight variance of this question: Possible to use a singleton with
This question: Best way to return status flag and message from a method in
I am coding this layout as a wordpress theme and having a slight problem
I've wrote this simple piece of code. And I have a slight problem with

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.