When declaring variables in an interface what is the difference between the two:
@interface thing:NSObject {
int x;
int y;
}
@property int x, y;
2:
@interface thing:NSObject {
@public
int x;
int y;
}
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.
@public is an access modifier that means you can access an attribute directly like this:
@property means that compiler should create accessor methods (if you’re using @synthesize).
An important thing is that property doesn’t necessarily match an attribute. You can create smth like this:
and then implement it:
However this is very rough and incomplete explanation (there is much more under properties). Read some articles/books about ObjC.