I have this code:
.h:
@interface ColorPickerView : UIViewController {
HSBEditView *hsbEditView;
}
.m:
hsbEditView = [[HSBEditView alloc] initWithFrame:CGRectMake(0, 0, 280, 46) H:h S:s B:b];
As i’m typing, this initWithFrame method is one suggested and I pressed tab to fill it in correctly.
The problem is, that last line there, the one in the m file, gets this warning:
Incompatible objective-c types assigning '*', expected '*'
Incompatible objective-c types assigning 'struct HEXEditView *', expected 'struct HSBEditView *'
HEXEditView is another view i have, but as you can clearly see, there is no mention of it in this line.
EDIT:
Implemented like so:
-(HSBEditView *)initWithFrame:(CGRect)frame H:(float)hue S:(float)saturation B:(float)brightness {
[super initWithFrame:frame];
...
return self;
}
EDIT: Solution found! I had to rename them to something slightly different, because that method had the same name as the init method in another class. I’d still love to know how to solve this problem properly though (if there is another way), because renaming the init method isn’t ideal?
To avoid renaming the method, you can cast the alloc:
That will silence the compiler warning.