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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:45:01+00:00 2026-06-14T06:45:01+00:00

I have a lightweight c++ class needed to be ported to Objective-C to exploit

  • 0

I have a lightweight c++ class needed to be ported to Objective-C to exploit the facilities provided by NSObject. There will be thousands of instances of the C++ class, and i dont want to add to much overhead by wrapping it in a NSObject derived class.

how big is NSObject?

  • 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-14T06:45:03+00:00Added an answer on June 14, 2026 at 6:45 am

    First of all, you should descend from NSObject. There is no tangible benefit to not doing so. NSObject adds nothing in terms of storage over the lowest level representation of a class but adds an awful lot of behaviour that will allow your classes to act correctly with the runloop, with the normal collections (eg, NSArray or NSDictionary) and with just about everything else.

    To answer your question specifically:

    #import <objc/runtime.h>
    
    ...
    
    NSLog(@"obj size: %zd", class_getInstanceSize([NSObject class]));
    

    Outputs ‘4’ on iOS and ‘8’ on 64-bit OS X. So the answer you’re looking for is ‘the natural size of an integer’. NSProxy is the same size, UIView (on iOS) is 84 bytes.

    Documentation for class_getInstanceSize is here — it explicitly returns “[t]he size in bytes of instances of the class cls”, as the name says.

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

Sidebar

Related Questions

Is there a small, lightweight solution for javascript class inheritance that will work well
I have a lightweight class I use to keep keep track of who the
I have an IList of type Breadcrumb which is just a lightweight class that
I have a lightweight online shopping site based on JSP and XML, and I'm
have written this little class, which generates a UUID every time an object of
I'm writing a lightweight class whose attributes are intended to be publicly accessible, and
what is the best Solution for mapping class object to lightweight class object by
I have a situation in Objective-C where a Java-style enum would be very helpful.
I have a python class, and I need to add an arbitrary number of
I have a domain model that looks like this: case class Account(id: Int, name:

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.