What is wrong with this Objective-C syntax?

curiouswebster
curiouswebster used Ask the Experts™
on
@interface Test : NSObject {

@private
    -(int)testInt;
}

@end

What am I missing? The compiler generates 4 errors over it?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
kaufmedGlanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Commented:
Have you imported the appropriate header for NSObject? What are the errors listed?
curiouswebsterSoftware Engineer

Author

Commented:
This compiles:

@interface AbstractQuery : NSObject

-(NSString*) name;
-(NSString*) question;
-(NSArray*) answers;
-(int) correctAnswerIndex;

@end

But this fails:

@interface AbstractQuery : NSObject {

@private
-(NSString*) name;
}
-(NSString*) question;
-(NSArray*) answers;
-(int) correctAnswerIndex;

@end

with the attached errors:
Errors.tiff
Commented:
That's because methods are always public in Objective-C.
curiouswebsterSoftware Engineer

Author

Commented:
thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial