2

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 ?

James Franco
  • 4,516
  • 10
  • 38
  • 80

1 Answers1

6

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
Nate Lee
  • 2,842
  • 1
  • 24
  • 30
  • Thanks that did the trick could u tell me why we had to move that out of the bracket? – James Franco Mar 24 '15 at 03:37
  • It's a matter of properties vs instance variables. See http://stackoverflow.com/questions/7057934/property-vs-instance-variable 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" – Nate Lee Mar 26 '15 at 20:28