I have a data source that is passing me a hex string (such as 11C01) that I need to convert each character in it into an integer or byte value so that I can use it as a bit field (i.e. doing things like value | 0x01 == 0 like you would in old C-style bit fields). The language for this will be Swift.
For the life of me I cannot find a way to convert a character containing a hex value into an integer without doing some weird round-about putting into NSData then converting it from there or doing it using C in an Objective-C class. Just looking for something in Swift to do this instead of resorting to that.
A sample string would be this: 11C01 I need it to create an array of bytes or integers like this: 0x1, 0x1, 0xC, 0x0, 0x1.
The output should be an int or byte that I can do the bitwise operation on.
How would I go about doing this?
Thanks in advance!