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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:24:55+00:00 2026-05-26T21:24:55+00:00

I have a new object inherited from NSObject Car *myCar = [[Car alloc] init];

  • 0

I have a new object inherited from NSObject

Car *myCar = [[Car alloc] init];

This returns 16, the size of a Car object

printf("myCar object: %d\n", sizeof(*myCar));

plz help me to make it clear, thanks

  • 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-26T21:24:56+00:00Added an answer on May 26, 2026 at 9:24 pm

    sizeof in this case works like C.

    As bbum said, you should not use sizeof on NSObject types (but pointers to NSObjects are ok). Clang forbids requesting the sizeof and object. The objc runtime should be your reference if you need an object’s size because the actual size of an objc object is not a static (compile-time) value, it is determined at runtime.

    Given these types:

    @interface A : NSObject
    @end
    
    @interface B : A
    {
        uint64_t ivar;
    }
    @end
    

    And these messages:

    printf("Class size is %lu\n", sizeof(Class)); // << for NSObject.isa
    printf("NSObject size is %lu\n", sizeof(NSObject));
    printf("A size is %lu\n", sizeof(A));
    printf("B size is %lu\n", sizeof(B));
    

    On 64 bit, we get:

    Class size is 8
    NSObject size is 8
    A size is 8
    B size is 16
    

    And on 32 bit, we get:

    Class size is 4
    NSObject size is 4
    A size is 4
    B size is 12
    

    There’s a little example which shows you why sizes grow. For more detail, here is the wikipedia page.

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

Sidebar

Related Questions

Suppose I have this code: var myArray = new Object(); myArray["firstname"] = "Bob"; myArray["lastname"]
Trying to do an insert, I have: jdbcTemplate.update(insert into...., new Object[]{foo.getId(), foo.getName()}) foo.getId() returns
I have a script which creates a user-defined object like this: obj = new
I have a custom control inherited from RichTextBox. This control has the ability to
I have a base user control (inherited from System.Web.UI.UserControl ) public delegate void MyEventHandler(object
i have an UI object VehicleUI which is inherited from Vehicle. It's the same,
I have RPC service that returns an object of type GameEvent that extends from
I have a new object with a collection of new objects within it on
I have an array an a timer that adds a new object to my
Is it possible in jax-ws to have a webmethod that creates a new object

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.