Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type of property 'shapeMatched' does not match type of accessor 'setShapeMatched:'

I'm developing an iPhone 4 application and I having problems with the class:

    @interface Pattern : NSObject {

        int maxNumShapes;
        NSMutableArray* shapes;
        NSMutableArray* shapeMatched;
        CGSize bounds;
    }
    @property (nonatomic, retain, readonly) NSMutableArray* shapes;
    @property (nonatomic, retain, readonly) NSMutableArray* shapeMatched;

    ...
    - (void) setShapeMatched:(ShapeType)type;

@end

And its implementation:

- (void) setShapeMatched:(ShapeType)type {
    int index = 0;
    if (shapes != nil)
    {
        for(Object2D* obj in shapes)
        {
            if (obj.figure == type)
            {
                [shapeMatched replaceObjectAtIndex:index 
                                        withObject:[NSNumber numberWithBool:YES]];
                obj.withFillColor = YES;
                break;
            }
            else
                index++;
        }
    }
}

I get the following warning:

Type of property 'shapeMatched' does not match type of accessor 'setShapeMatched:'

How can I fix this warning?

like image 442
VansFannel Avatar asked Dec 01 '22 07:12

VansFannel


2 Answers

You method - (void)setShapeMatched:(ShapeType)type is probably intended to change something in the shapeMatched array, however, its name overwrites the setter of your property for that very same array.

It's unclear, but if you really want to overwrite the setter, the argument must be of type NSMutableArray * since that's the type of your property. Otherwise, if you method just do something else, rename it to avoid the collision. setShapeMatchedType:(ShapeType)t might be a good option.

like image 125
sidyll Avatar answered Dec 04 '22 07:12

sidyll


You need to rename your custom setShapeMatched: to something else (like setMyShapeMatched). setShapeMatched: is already in use as the setter for your declared property.

like image 35
MusiGenesis Avatar answered Dec 04 '22 06:12

MusiGenesis