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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:55:13+00:00 2026-06-09T15:55:13+00:00

In the Hello World tutorial, I tried to comment out the ‘@synthesize userName =

  • 0

In the Hello World tutorial, I tried to comment out the ‘@synthesize userName = _userName;’ in the HelloWorldViewController.m file. According to https://developer.apple.com/library/mac/#documentation/cocoa/conceptual/objectivec/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW1, “… You use the @synthesize directive to tell the compiler that it should synthesize the setter and/or getter methods for a property if you do not supply them within the @implementation block.”

The strange thing to me is that even with ‘@synthesize userName = _userName;’ commented out, the later appearance of statements in the HelloWorldViewController.m file, such as [self.userName length] and self.userName = [[self textField] text], is not considered to be an error or warning by Xcode (I am on V4.4.1). How is this possible?

As I understood, if @synthesize is missing for a declared property, the property is not even defined. What’s more is no @synthesize means no getter or setter method for the property implemented. How come the Hello World app still compiles and runs perfect?

Part of code is here:

#import "HelloWorldViewController.h"
@implementation HelloWorldViewController
//@synthesize userName = _userName;
@synthesize label;
@synthesize textField;

...

- (IBAction)changeGreeting:(id)sender {

[self setUserName:[[self textField] text]];

if([self.userName length]==0){
    [self setUserName: @"World"];
}
NSString *greeting=[[NSString alloc] initWithFormat:@"Hello, %@!", self.userName];
self.label.text=greeting;

- (IBAction)changeGreeting:(id)sender {

self.userName = [[self textField] text];

if([self.userName length]==0){
    [self setUserName: @"World"];
}
NSString *greeting=[[NSString alloc] initWithFormat:@"Hello, %@!", self.userName];
self.label.text=greeting;

}

@end

Xcode gives no warning or error for the code above.

  • 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-09T15:55:15+00:00Added an answer on June 9, 2026 at 3:55 pm

    As of Xcode 4.4 properties are automatically synthesized. If you declare a property that is readwrite and you don’t implement the getter and the setter method for that property, Xcode will insert @synthesize property = _property automatically for you. For readonly properties you mustn’t implement the getter method to get this behavior.

    If you implement the setter and/or getter method Xcode will not synthesize the property automatically and won’t create an iVar for you, either. In that case you can still add the @synthesize yourself.

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

Sidebar

Related Questions

I am following this tutorial https://developer.android.com/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually
I'm trying to run through the Hello World tutorial for the iPhone and i
Does anyone have a hello world sample or tutorial for creating an Eclipse plugin
I'm following this tutorial to create a simple Hello World extension for Chrome: http://code.google.com/chrome/extensions/getstarted.html
Let's start with the Hello World program detailed at http://developer.android.com/resources/tutorials/hello-world.html . Let's add the
I am following this tutorial that is like the hello world for post-commit I
I am going through the android hello world tutorial, and have been stuck when
Looking into ExtJS 4 and I am attempting to do the Hello World tutorial
I have a compiling problem. I followed tutorial about Hello world program for Android
I'm trying to run the hello world tutorial for the Google app engine in

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.