Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DragonJade

macrumors 6502
Original poster
May 2, 2009
324
8
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
Code:
#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
Code:
#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
Code:
@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
Code:
#import "PolygonShape.h"

@implementation PolygonShape

@end

Any help would be appreciated. Thanks.
 

xsmasher

macrumors regular
Jul 18, 2008
140
0
Very tricky. The @property directive has to be outside the brackets of the @interface section. Try this:

polygonShape.h
Code:
@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

macrumors 6502
Original poster
May 2, 2009
324
8
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.