tags:

views:

100

answers:

1

I'm not sure what is wrong with this setter function declaration because the other setter functions in the same class have the same syntax and they don't cause errors. I thought it may have been syntax errors in lines before this declaration, but I've checked those too and can't seem to find the cause. Here is the code:

#import <Foundation/Foundation.h>


@interface PolygonShape : NSObject {

}

@property int numberOfSides;
@property int minimumNumberOfSides;
@property int maximumNumberOfSides;
@property (readonly) float angleInDegrees;
@property (readonly) float angleInRadians;
@property (readonly) NSString *name;

-(void)setNumberOfSides:(int);   // Error: expected idenitifier before ';' token
-(void)setMinimumNumberOfSides:(int);
-(void)setMaximumNumberOfSides:(int);

-(id)initWithNumberOfSides:(int)sides minimumNumberOfSides:(int)min maximumNumberOfSides:(int)max;
-(id)init;

-(float)angleInDegrees;
-(float)angleInRadians;

-(NSString*)name;

-(NSString*)description;

@end

I also thought it may have been because I am synthesizing the function in the implementation, but I am doing that with both setMinimumNumberOfSides and setMaximumNumberOfSides as well. If you need code from my implementation to help solve this, leave a comment and I'd be happy to post it.

+8  A: 

Have you tried adding a parameter name?

-(void)setNumberOfSides:(int)sides;
-(void)setMinimumNumberOfSides:(int)sides;
-(void)setMaximumNumberOfSides:(int)sides;
Daniel A. White
Indeed. As compared to ANSI C's function declaration, you can't drop parameter names.
Yuji
Ah thanks, I'm actually taking a networks class for credit in which we exclusively program in C so that's probably where the confusion came from. Thanks!
Boontz
@Boontz: You should accept this answer as it is correct.
JeremyP