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

  • Home
  • SEARCH
  • 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 8437711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:30:35+00:00 2026-06-10T07:30:35+00:00

Since xcode 4.4 you don’t need to @synthesize properties anymore ( see here ),

  • 0

Since xcode 4.4 you don’t need to @synthesize properties anymore (see here), the compiler does it for you. So, why does the compiler complain

use of the undeclared identifier _aVar

in my viewDidLoad method of ViewControllerSubclass:

@interface ViewController : UIViewController
@property (assign, nonatomic) int aVar;
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.aVar = 5;
    NSLog(@"Super value: %d", _aVar);
}
@end

@interface ViewControllerSubclass : ViewController
@end

@interface ViewControllerSubclass ()
@property (assign, nonatomic) int aVar;
@end

@implementation ViewControllerSubclass
- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"Subclass value: %d", _aVar);
}
@end

If I move everything to the one file instead of 4 separate files for the respective interfaces and implementations, the compiler instead complains that _aVar is private. But _aVar should have been automatically synthesized in my ViewControllerSubclass.

Still keeping everything in 1 file, if I move the initial property declaration to a class extension:

@interface ViewController ()
@property (assign, nonatomic) int aVar;
@end

The build still fails saying that _aVar is private.

If I go back to the 4 file setup for the respective interfaces and implementations xcode builds without even a warning.

If I then run the code:

[[[ViewControllerSubclass alloc] init] view];

the log statements in the above examples print out the following:

Super value: 0

Subclass value: 5

It makes sense that NSLog(@"Super value: %d", _aVar); produced a result of 0 because this variable is supposed to be private to the superclass. But then, why does NSLog(@"Subclass value: %d", _aVar); produce a result of 5??

This is all very odd.

  • 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-10T07:30:36+00:00Added an answer on June 10, 2026 at 7:30 am

    When you make the superclass declaration public, the compiler won’t attempt to re-synthesize the property; it assumes that’s been taken care of in the superclass. Thus, _aVar is not in scope anywhere in the subclass. It’s private anyway, so even when you put them all in the same file that’s why you see those errors.

    However when you make the superclass property declaration inside the class extension, the compiler will auto-synthesize the property for both the superclass and the subclass. This ends up with both classes having private instance variables _aVar (with two distinct addresses). However, when the superclass viewDidLoad method sets the property, the method invokes the subclass’s accessors, which set the value of the subclass’s private _aVar variable, and not the superclass’s. So that explains why you see the superclass value not changing.

    Hope this helps!

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

Sidebar

Related Questions

Since Xcode 4.2 comes with LLVM 3.0 we're finally able to use automatic synthesizeation
Since, I don't have the iPod touch simulator in xcode, and I don't have
I noticed since Xcode 4.3, the audio unit templates are gone and the audio
Since recent update Xcode 4.3 now seems to default to LLDB debugger. I just
Since upgrading to the latest Xcode 3.2.1 and Snow Leopard, I've been getting the
Using Xcode 4.3.2. Since yesterday, I can't upload to ITunes Store. I can't find
since memcpy should be highly optimized nowadays, does it still make sense to optimize
Since now I have only used plugin for editing and the way I use
Is there any way to use a script to add files to an Xcode
I have several projects that with the upgrade to Xcode 4.3 don't crash but

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.