metova / ThunderCats

ThunderCats is a lightweight collection of utility extensions added to existing Foundation & UIKit classes.
https://metova.com
MIT License
19 stars 4 forks source link

Clean up `UIColor` extensions. #14

Closed nhgrif closed 8 years ago

nhgrif commented 8 years ago

tc_isEqualToColor: should simply use CGColorEqualToColor.


tc_colorWithHexString: needs quite a lot more clean up.

We have it marked as returning __tc_nonnull, but it should more likely return __tc_nullable. The only valid inputs should be in the following formats:

Where r, g, and b represent valid hex characters for the red, green, and blue values. Yet, if a string not matching this format is passed in, we simply happily try to generate some sort of color and return what may or may not be the valid color, although I'll argue that if we return anything but nil (rather than throw an exception) for anything outside those four formats, we're returning something invalid.

We'll need to just mark this method as deprecated until 3.0 and add another method that does it correctly.


The tests should also be cleaned up as noted in this comment.

nhgrif commented 8 years ago

Appending four other valid formats to this issue:

Where r, g, b, and a, represent valid hex characters for the red, green, and blue values.

@jrichardson0104