approach 1:
@interface MyController : UIViewController {
UILabel *myText;
}
@property (nonatomic, strong) UILabel *myText;
approach 2:
@interface MyController : UIViewController
@property (nonatomic, strong) UILabel *myText;
approach 3:
@interface MyController : UIViewController {
UILabel *myText;
}
I have read some articles talking about this kind of stuff but I still do not really realize which approach I have to adopt.
I also found that someone said approach 1 is a old way so I would like to know the best practice for ios sdk 6 using ARC.
I know that declaring variables using property is a easy way for generating getter and setter and someone suggested using it. However, I would like to ask in case a variable is not for calling by another class, is it necessary for the variable using property? and set it as private variable inside the interface? Or is it better for a variable only declaring inside the interface? I would like to learn the best practice so please forgive me if this is a silly question.
Moreover, some developers write @synthesize in this way
@synthesize myText=_myText;
but some write this:
@synthesize myText;
I would also want to know the difference and which one is preferable?
Thank you very much!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…