PDA

View Full Version : AT_NAME errors




DragonJade
May 2, 2009, 11:43 AM
Hi everyone. I'm having a go at Stanford's iPhone course and have hit upon a little problem.

I'm currently on the Assignment 2B walkthough and up to the end of the "Connect the Controller to the Model" section where you do a build to check everything's ok. It's at this point I get two AT_NAME errors.

This is what my .h and .m files with the errors look like:

controller.h

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "PolygonShape.h"


@interface Controller : NSObject {
IBOutlet UIButton *decreaseButton;
IBOutlet UIButton *increaseButton;
IBOutlet UILabel *numberOfSidesLabel;
IBOutlet PolygonShape *polygon;

}

- (IBAction)decrease;
- (IBAction)increase;
@end


controller.m

#import "Controller.h"

@implementation Controller

- (IBAction)decrease {

NSLog(@"Iím in the decrease method");
}

- (IBAction)increase {
NSLog(@"Iím in the increase method");
}

@end


polygonShape.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;
}

@end


polygonShape.m

#import "PolygonShape.h"

@implementation PolygonShape

@end


Any help would be appreciated. Thanks.



kainjow
May 2, 2009, 12:15 PM
Your syntax for your @properties is incorrect. Take a look here http://theocacao.com/document.page/510

xsmasher
May 2, 2009, 12:23 PM
Very tricky. The @property directive has to be outside the brackets of the @interface section. Try this:

polygonShape.h

@interface PolygonShape : NSObject {

int numberOfSides;
int minimumNumberOfSides;
int maximumNumberOfSides;
float angleInDegrees;
float angleInRadians;
NSString *name;
}

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

@end


It seems redundant, but a instance variable doesn't always have a property, and and property doesn't always have an instance variable (it could be computed from two other ivars.)

You could also get the same error from missing @end's or missing semicolons, but yours look fine.

DragonJade
May 2, 2009, 08:58 PM
DOH! I realised what I've done wrong now. I deleted polygon.h .m and had to retrieve them from Trash to stick back into the project. I must have copied over the wrong ones and not even noticed that all the (correct) code from them was missing. If you guys hadn't mentioned the @property I don't think I would have realised as I was sure that I had put them in the right place.

I guess sometimes you can't see the wood for the trees. Thanks again.