Incompatible type for argument 1 of 'setBounds'

Posted by Brandon on Stack Overflow See other posts from Stack Overflow or by Brandon
Published on 2010-02-01T20:51:52Z Indexed on 2010/04/24 19:43 UTC
Read the original article Hit count: 190

Filed under:

I am trying to do my own custom classes and learn C and Objective C. I'm recieving the error that there is an incompatible type for argument 1. I've defined a struct and class like this:

typedef enum {
 kRedColor,
 kGreenColor,
 kBlueColor
} ShapeColor;


typedef struct {
 int x, y, width, height;
} ShapeRect;


@interface Shape : NSObject
{
 ShapeColor  fillColor;
 ShapeRect   bounds;
}

- (void) setFillColor: (ShapeColor) fillColor;
- (void) setBounds: (ShapeRect) bounds;
- (void) draw;

@end // Shape

Then I import the Shape.h file(code above) and try and create a shape like this:

id shapes[4]; // I'm different!

ShapeRect rect0 = { 0, 0, 10, 30 }; shapes[0] = [Shape new]; [shapes[0] setBounds: rect0];

I get the error that setBounds is incompatible. For some reason it isn't looking at the Shape.h class for the setBounds method and it is instead looking at the default setBounds method? Is there something I'm doing wrong? Thanks!

© Stack Overflow or respective owner

Related posts about objective-c