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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:38:23+00:00 2026-05-30T17:38:23+00:00

In Objective-C, what is the actual difference between putting an instance variable in .h

  • 0

In Objective-C, what is the actual difference between putting an instance variable in .h files vs. putting it in .m files? Is the end-result any different? What particular mechanism allows for this? How come this is possible in Objective-C and not in, say, C++?

If I adopt the style of putting instance variables in .m files, this is only suitable for private instance variables, right? I should always put my protected instance variables in .h files so they can be properly inherited by subclasses, right? Or is there a way to let protected ivars in .m files be inherited somehow?

  • 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-30T17:38:25+00:00Added an answer on May 30, 2026 at 5:38 pm

    Putting additional instance variables in class extensions was not possible prior to Clang/LLVM 2.0. Objective C compiler “assembles” the ivars of the class from the definitions in the header and in the class extension, arriving at the final layout.

    Class extensions is a relatively new language feature of Objective-C, so its absence in other languages, such is C++, should come as no surprise. Yet other languages, such as C#, may implement a comparable feature with partial classes.

    You are correct about the second part: only private instance variables and properties are suitable for use in class extensions; protected and of course public instance variables should be in the .h file.

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

Sidebar

Related Questions

What is an actual name of instance variable, say, topSpeed, as from lectures of
In Objective-C on Apple there is something called Key-Value Coding that allows you to
is it possible to declare a variable length array with global scope in objective-c?
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
In Objective-C for iOS, how would I remove the last character of a string

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.