As we are updating tc_colorWithHexString: to throw an invalid argument exception if an invalid string is passed in, we should provide users with an easy way to pre-check their string to determine if it is valid for converting to a UIColor using tc_colorWithHexString:.
We should add a class method to UIColor called tc_isValidHexColorString: which takes an NSString argument and returns a BOOL. If the string would throw an exception from tc_colorWithHexString:, then tc_isValidHexColorString: should return NO. If the string would correctly generate a UIColor out of tc_colorWithHexString:, then tc_isValidHexColorString: should return YES.
When working on this method, please keep an eye out for duplicated logic between the two aforementioned methods and refactor out anything that can be.
As we are updating
tc_colorWithHexString:
to throw an invalid argument exception if an invalid string is passed in, we should provide users with an easy way to pre-check their string to determine if it is valid for converting to aUIColor
usingtc_colorWithHexString:
.We should add a class method to
UIColor
calledtc_isValidHexColorString:
which takes anNSString
argument and returns aBOOL
. If the string would throw an exception fromtc_colorWithHexString:
, thentc_isValidHexColorString:
should returnNO
. If the string would correctly generate aUIColor
out oftc_colorWithHexString:
, thentc_isValidHexColorString:
should returnYES
.When working on this method, please keep an eye out for duplicated logic between the two aforementioned methods and refactor out anything that can be.