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?
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.
You need to rename your custom setShapeMatched:
to something else (like setMyShapeMatched
). setShapeMatched:
is already in use as the setter for your declared property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With