In an .h file, what is the difference between:
@interface ViewController : UIViewController
@property (strong, nonatomic) UIView* myView;
And
@interface ViewController : UIViewController{
UIView* myView;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
The main difference is that a @property is visible to other objects, and can be accessed by these using an instance of your class.
You can use @synthesize in your implementation file to automate definition de getter setter functions in your implementation.
Updated (following @Graham Lee‘s suggestion)
According to the visibility specifier for your instance variable (@protected / @private / @public) , the ivar can be used in your implementation file, subclasses or other classes. The implicit value is @protected, so in your example it will be visible to your implementation file and subclasses.