Hello everyone this is my first post.
I am at a loss as to why I'm getting error message in my code. It is supposed to output the area and perimeter of a rectangle. Instead of completely changing the code, I want to narrow in on the line of code involved. Here is the code. I pointed out the lines in question.
recty.h:
#import <Foundation/Foundation.h>
@interface recty: NSObject {
int width;
int height;
}
@property int width, height;
- (int)area;
- (int)perimeter;
- (void)setWH:(int) w:(int)h; // 'w' used as name of previous parameter rather than as part of selector
@end
recty.m:
#import "recty.h"
@implementation recty
@synthesize width, height;
- (void)setWH:(int) w:(int) h {
//'w' used as name of previous parameter rather than as part of selector
}
- (int)area {
return width * height;
}
- (int) perimeter {
return (width + height) * 2;
}
@end
main.m:
#import <Foundation/Foundation.h>
#import "recty.h"
int main(int argc, const char * argv[]) {
recty *r = [[recty alloc]init];
[r setWH:6 :8];
@autoreleasepool {
// insert code here...
NSLog(@"recty is %i by %i", r.width, r.height);
NSLog(@"Area = %i, Perimeter = %i", [r area], [r perimeter]);
}
return 0;
}
Does it have to do with how I'm declaring parameters? I listed the error info in the code. I use Xcode and the info on making the code is 2 years old. Maybe some of the code is outdated?