Property type 'shapeMatched' does not match accessor type 'setShapeMatched:'

I am developing an iPhone 4 application and am 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?

+4
source share
2 answers

You need to rename your own setShapeMatched: to something else (e.g. setMyShapeMatched ). setShapeMatched: already used as the installer for your declared property.

+6
source

Probably, the method - (void)setShapeMatched:(ShapeType)type should change something in the shapeMatched array, however its name overwrites the installer of your property for the same array.

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

+14
source

Source: https://habr.com/ru/post/1382690/


All Articles