I’m getting this warning when I’m trying to compare RGB components of two UIColors
In .h file, I declared this
-(int) ColorDiff:(UIColor *) color1 :(UIColor *)color2;
In .m file
- (int) ColorDiff:(UIColor *) color1 :(UIColor *)color2{
... //get RGB components from color1& color2
// compute differences of red, green, and blue values
CGFloat red = red1 - red2;
CGFloat green = green1 - green2;
CGFloat blue = blue1 - blue2;
// return sum of squared differences
return (abs(red) + abs(green) + abs(blue));
}
And then in same .m file, I compare 2 UIColors like this
int d= ColorDiff(C1,C2);// I got the warning right here.
I did research and people say I must include the header file. I did this but didn’t help in my case.
Why am I getting this error?
It’s because you defined your function as a instance method, not a function. There are two solutions.
One of which is this to change your method declaration to this:
Or, you can change your call to this: