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

  • Home
  • SEARCH
  • 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 7820515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:19:45+00:00 2026-06-02T07:19:45+00:00

In Objective-C, is id exactly the same as void * in C? (a generic

  • 0

In Objective-C, is id exactly the same as void * in C? (a generic pointer type).

If so, when we use

id obj = [[Fraction alloc] init];
[obj methodName];
obj = [[ComplexNumber alloc] init];
[obj anotherMethodName];

When the method is called, by what way does the program know what class obj is?

  • 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-02T07:19:46+00:00Added an answer on June 2, 2026 at 7:19 am

    id is not the same as a void *. id is a pointer to an Objective C object of unknown type; like the object datatype of C# or Java. A void* can point at anything; a non-nil id is expected to point at a data structure that’s common to all ObjC objects and contains a pointer to their respective class data.

    The ObjC runtime – the implementation of alloc/init/etc. – makes sure all the valid objects have the right class pointer in them.

    IIRC, in Apple’s implementation the pointer-sized variable that id points at is, in fact, the pointer to the class.

    In the class’ data block, there’s a list of methods that maps method signature to the function pointer to the method implementation. From there, it’s a fairly simple lookup that happens in run time when you send a message to (i. e. call a method in) an object. Also a pointer to the base class so that the method lookup may continue up the inheritance tree.

    That, by the way, is why derefencing a void pointer is a compiler error while sending messages to an id is legal, if statically unsafe.

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

Sidebar

Related Questions

What exactly does the Objective-C garbage collector collect? For example, if I'm writing a
I wanted to know , How exactly does an Objective C object gets created.
Does anyone know exactly what the @package directive is used for in Objective-C? The
What exactly does the __block keyword in Objective-C mean? I know it allows you
Objective-C uses a sophisticated message-passing system when one object calls a method on another
Objective: In support of a Windows Service that may have multiple instances on a
Objective: My script will download a remote file upon form submission, since the file
Objective Change these filenames: F00001-0708-RG-biasliuyda F00001-0708-CS-akgdlaul F00001-0708-VF-hioulgigl to these filenames: F0001-0708-RG-biasliuyda F0001-0708-CS-akgdlaul F0001-0708-VF-hioulgigl Shell
Objective C is new for me. How can I change the font of a
Objective Initialize a new addition problem for users to solve when they visit /task

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.