I am getting this error when i declare my instance variable as
@interface FOO : NSObject
{
@public
int a;
}
@public
-(id)init;
-(void)dealloc;
@end
error: expected identifier or ‘(‘ before ‘public’
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.
You do not use
@publicor other access keywords outside the interface definition, as you don’t declare public or private methods in Objective-C.As long as you expose a method in a header/interface it’s automatically publicly accessible from outside the class. If you only add an implementation, but don’t expose it in the header/interface (or only expose it in a class extension), it’s private.
Now why you would want to declare a public
int ainstance variable (instead of using a property) or explicitly declare two methods thatNSObjectalready has is beyond me.