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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:30:03+00:00 2026-06-01T09:30:03+00:00

I wanted to know , How exactly does an Objective C object gets created.

  • 0

I wanted to know , How exactly does an Objective C object gets created. I have been reading different blog posts and apple docs but I could only find incomplete information here and there about ivar and objc_class structures ad various other runtime methods and structures.

But I still did not get, What happens when we call alloc on a Class and how are superclass data members added to the structure ?

If possible, can any one Explain this to me or point me to the source code of these methods that actually allocate memory ?

  • 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-01T09:30:05+00:00Added an answer on June 1, 2026 at 9:30 am

    When alloc is called, it (as any other message send) first gets transformed (by the compiler) into one of the objc_msgSend* functions. This function will get the class structure pointer as its first argument, and @selector(alloc) as its second.

    Then, objc_msgSend looks up the corresponding method implementation of +[class alloc], which is, in general, not overridden (custom initialization is conceptually done in -initWith…), so it will generally be +[NSObject alloc]. It is likely that alloc simply calls +[NSObject allocWithZone:]; that function’s implementation might do the following steps:

    1) It finds the class’ istance size (probably via class_getInstanceSize())
    2) It allocates memory, most likely using the class_createInstance() function. This function clears the allocated memory to zeroes (that’s why, as the specs say, all your ivars are explicitly initialized to 0 on startup), then sets the newliy created object’s isa pointer to the class structure itself.
    3) The allocWithZone: methods returns the fresh object pointer to alloc
    4) alloc returns the object pointer to the sender, most likely it will run into [Class initWith...:].

    Hope this helps. Also, apart from the Obj-C runtime docs, don’t forget to check the GNUstep NSObject implementations. That’s a logic and possible way how the GNU people implemented it and how Apple might have implemented it.

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

Sidebar

Related Questions

I'm new to iphone development, and I wanted to know. exactly what does the
I've been hearing/reading a lot about covariance issues in C# and I wanted to
I have a file shredder on my computer, and I wanted to know if
I wanted to have more than one controller and view for same object/model in
This could be weird, Have you ever come across a blog which you wanted
I wanted to know what exactly is run time environment at system level(operating system).
I saw the code written somewhere online, and I wanted to know what exactly
I wanted to know where exactly in xcode do I place a x.509 certificate
I wanted to know the command which is exactly equal to php require in
I basically wanted to know what exactly a virtual processor is. At IBM's site

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.