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.