3

I am a beginner in objective C and I am using the following code I am using xcode6

// Car.h
#import <Foundation/Foundation.h>

@interface Car : NSObject {
    NSString *simple_name;  //This is private
    @property int mssp;     //Cant use @property Error illegal visibility specification
}

-(void) sayHi:(NSString*)msg ;
@end

Any suggestions on why I am getting this error ?

1
  • Try putting "@property int mssp" outside of the brackets? Commented Mar 24, 2015 at 2:20

1 Answer 1

7

Move @property int mssp; out of the brackets:

// Car.h
#import <Foundation/Foundation.h>

@interface Car : NSObject {
    NSString *simple_name;  //This is private
}
@property int mssp; 

-(void) sayHi:(NSString*)msg ;
@end
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks that did the trick could u tell me why we had to move that out of the bracket?
It's a matter of properties vs instance variables. See stackoverflow.com/questions/7057934/… or google the topic. @Chuck states: "A property is a more abstract concept. An instance variable is literally just a storage slot, like a slot in a struct. Normally other objects are never supposed to access them directly. A property, on the other hand, is an attribute of your object that can be accessed (it sounds vague and it's supposed to). Usually a property will return or set an instance variable, but it could use data from several or none at all"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.