I’ve got HEX colors as NSStrings and want to check if a particular string contains an F at the first, third, or fifth character, but to ignore it if it contains an F at the second, fourth or sixth character.
This is to identify if the color in question is a light color or not.
I searched for this, but only found answers regarding how to find character ranges.
Have you tried to use
characterAtIndex? You can use the method to retrieve the string at the first, third and fifth character (of course one at a time) and compare it with F.Note that all your HEX colors must be 6 characters. Sometimes, you can represent a color with only three hex values (eg. FFF would still give you white in HTML). So if your color is represented using three chars only, and you try to get the char at index 5, the method will throw an ‘out of range’ exception.