I am trying to convert hex color values into floats. I have a DataController class with a method like so:
+(float)floatFromHexColorInteger:(float)hexFloat {
float newColorFloat = hexFloat / 255.0f;
return newColorFloat;
}
I want to use it to easily get a color value between 0.0 and 1.0, so I can use it like so:
float colorFloat = [DataController floatFromHexColorInteger:79.0f];
//error on line above is:
//Classes/RootViewController.m:53: error: incompatible types in assignment
self.navigationController.toolbar.tintColor = [UIColor colorWithRed:colorFloat green:colorFloat blue:colorFloat alpha:1.0f];
I’m getting a compiler error (2) on the first line, about incompatible types. Can anyone figure out why?
If
+(float)floatFromHexColorInteger:(float)hexFloatis declared somewhere (in the .h file for example), you should check that the return type isfloattoo.If it’s something else, the compiler may throw an error.