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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:18:50+00:00 2026-06-04T20:18:50+00:00

So in the guidelines it says: For code that will run on iOS only,

  • 0

So in the guidelines it says:

For code that will run on iOS only, use of automatically synthesized instance variables is preferred.

When synthesizing the instance variable, use @synthesize var = var_; as this prevents accidentally calling var = blah; when self.var = blah; is intended.

 // Header file
@interface Foo : NSObject
// A guy walks into a bar.
@property(nonatomic, copy) NSString *bar;
@end

// Implementation file
@interface Foo ()
@property(nonatomic, retain) NSArray *baz;
@end

@implementation Foo
@synthesize bar = bar_;
@synthesize baz = baz_;
@end

Question is, does this apply to public variables only or private too? It’s not really clear on the documentation, but would like to have some thoughts or perspective on why “if” this is only for public or private only? I think that it just makes sense for all public/private so that you don’t mess up ivars and using the property

  • 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-04T20:18:52+00:00Added an answer on June 4, 2026 at 8:18 pm

    I don’t think it particularly matters whether the variables in question are public or private. The practice of synthesizing under a different name makes it explicit when you are accessing the variable directly instead of using the generated accessor method.

    Perhaps there’s a different question underlying what you’re asking: should I typically access private ivars via the accessor or directly? I think most skilled iOS devs tend to use accessors unless there is some particular reason not to (performance, avoiding side effects like KVO, etc.). Doing so is more future-proof and allows for flexibility in the underlying implementation. In a very small way, you’re coding to an interface rather than an implementation.

    It also might be worth pointing out that the default behavior of Clang is going to change in the future so that property-backing ivars are synthesized named _foo by default. Clearly the powers-that-be consider consider underscoring ivars to be a best-practice.

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

Sidebar

Related Questions

I'm just reading my company's code guidelines and it says to never treat variables
on iOS Human Interface Guidelines it is clearly stated that an icon for spotlight
Are there any guidelines to writing Google App Engine Python code that would work
Guidelines for code-golf on SO We've all seen phone numbers that are put into
As the title says - what are your guidelines for when you should run
Are there any guidelines on when to use storyboards in an iOS project and
Android icon guidelines says to use icon of size 36*36pixels for ldpi and 48*48
In Apple's guidelines, I saw: 2.7 Apps that download code in any way or
The Challenge Guidelines for code-golf on SO The shortest code by character count to
From Android widget screen guidelines, http://developer.android.com/guide/practices/ui_guidelines/widget_design.html , we know that, home screen has 4*4

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.