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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:48:40+00:00 2026-06-11T03:48:40+00:00

Finally I’m transitioning to ARC. Sounds too late but all my projects have retrocompatiilty

  • 0

Finally I’m transitioning to ARC. Sounds too late but all my projects have retrocompatiilty to 3.0 (any news about App Store unsupporting?) so I can’t use it. But now I’m working in a new project with base deployment in iOS 5 so I’m using ARC.

My question is so simple. I’m used to declare private instance variables and public properties. For example:

@interface MyClass : NSObject {
@private

    Var *aVar_;
    Var *anotherVar_;
}

@property (nonatomic, readonly) Var *aVar;

@end

@implementation MyClass

@synthesize aVar = aVar_;

@end

Inside the class I work with instance variables, not properties.

But now I’m trying to avoid instance variables because I think there are not neccessary and redundant if I use proeprties, and I read time ago that is better to use properties instead of instance variable, but I’m not sure. That class now seems like that

@interface MyClass : NSObject

@property (nonatomic, readwrite, strong) Var *aVar;

@end

@interface MyClass()

@property (nonatomic, readwrite, strong) Var *anotherVar;

@end

@implementation MyClass

@synthesize aVar = aVar_;
@synthesize anotherVar = anotherVar_;

@end

In this case I’m still using instance variables (underscored) to manage my data because is less verbose and ARC takes into account all memory issues, but I don’t know if that is correct.

Also I have another question. The property of aVar in the first chunk of code is readonly but if I use only properties I have to make that property readwrite. If I want to make the public property readonly, do I have to declare a public readonly property in the @interface and a private readwrite in private @interface?

Thank you so much.

  • 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-11T03:48:42+00:00Added an answer on June 11, 2026 at 3:48 am

    The answer to your questions is somewhat complex, but generally you have the swing of it.

    Since ARC does all the memory management for you, its often simpler to just use an ivar (private to the class, declared in the implementation) for your internal needs. In that case all usages just use the name.

    With properties, you can as of Xcode 4.4 let Xcode synthesize the setter and getter, as well as the ivar. Auto-synthesized ivars are created with a leading “_” character.

    You can define a property as readonly in the implementation, leave it as readonly, and set it in your code as ‘_foo = ….’. [Many on this site would consider this a bad practice, my point is you can do it.]

    Xcode 4.4 has a warning titled “Implicit Synthesized Properties” with a default of NO. This creates a warning if you do not provide a @synthesize statement for each property, even though it will do the synthesis anyway.

    Personally, I use ivars whenever I can, and only define properties when I need to either make something public to other classes, or I have categories declared in multiple files (in which case I put the interface declaration of the class extension in its own file along with properties defined in it.)

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

Sidebar

Related Questions

I finally have this working now but would like to know how I can
Finally I have decided to get rid of aptana from eclipse but the Software
Finally decided to have a look at HTML5 & see what all the fuss
Finally I have ended up with this. But there is a minor issue not
I finally solved one problem but now i have another. I found out how
Finally I've got colorbox working fine. BUT it's not showing any buttons? Look here:
Finally deployed my ruby on rails 3.2 app but when trying to open it
Finally figured it out thanks to One Mad Monkey, but forgot quotes on my
I finally figured out how to implement pg_search's multisearch feature. But I'm having trouble
I finally have my C++ Builder 2010 installation the way I want it, with

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.