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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:21:10+00:00 2026-06-10T01:21:10+00:00

I am confused as to why some classes declare a property but do not

  • 0

I am confused as to why some classes declare a property but do not declare an ivar and vice versa.

Is it standard practice when declaring an instance variable to also declare it as a property as well?

Example:

@interface AppDelegate : NSObject <UIApplicationDelegate>
{
    UIWindow *window;
    UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

is just standard practice when declaring a class’s ivar to make it a property as well?

I get that the @property creates its own elongated setter (and getter with @synethesize) but why does it need to be an ivar as well?

  • 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-10T01:21:12+00:00Added an answer on June 10, 2026 at 1:21 am

    It doesn’t.

    In the old days, ivars were required to be declared in the @interface. This is actually still true for PPC and i386 (i.e. 32-bit intel) targets. This is because of the fragile base class problem, which required that all subclasses know the exact size of their superclass. As such, ivars need to be in the @interface or nobody can subclass the class.

    With the move to x86_64 and ARM, alongside obj-c 2.0 came a fix for the fragile base class problem. With this fix, class sizes no longer need to be known at compile time but can be deferred to runtime. Therefore, ivars can be declared in other places. Notably, an ivar can now be synthesized from a @property (more specifically the @synthesize line in the implementation). In Clang they can also be declared in a class extension block (which looks like @interface ClassName ()) or directly on the @implementation.

    Today, there are 3 reasons why you find ivars declared in @interface blocks:

    1. Old code (or programmers with old habits) that hasn’t been updated to take advantage of the ability to hide ivar declarations.
    2. Code that needs to run on PPC or i386.
    3. Code that, for whatever reason, wants their ivars to be public. This should never be the case.

    When writing code today that doesn’t need to target the old runtime, you should either synthesize your ivars from your properties (preferred), or if you need ivars that aren’t tied to properties you should declare them in a class extension or on your @implementation. The primary reason for this is because the header file documents the public API of your class and should not contain anything that’s not public. Ivars are not public, and therefore should not be in the header file.

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

Sidebar

Related Questions

Some of the HTML5 canvas demos are very impressive, but I'm a bit confused.
I confused with extends, i went with theory n solved some examples, But when
Recently, I was investigating into some details about classes in Ruby, and was confused
EDIT:: This might be simple for some but right now it has me confused.
I wrote some java classes, to evaluate/demo different Sorting algorithms. However I got confused
I'd like to know some best practice when designing c++ classes. To put it
I have got some confused about shared_ptr. Say, I have classes: class foo {
I'm looking through my textbook and I'm a little confused about some of the
This might be basic question, however I am confused on some .Net Concpets. I
For some reason this function confused me: def protocol(port): return port == 443 and

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.