64-bit incompatibility between CGFloat and colorWithString #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you encode a UIColor on a 64-bit device with stringValue and then try to recreate it via colorWithString, the resulting RGB values will not be correct. This is because [NSScanner scanFloat] is trying to decode a double value. On 64-bit platforms CGFloat is a double and needs to be decoded using scanDouble.
Note: this fix only works for the case where the source and destination platforms are the same, e.g. if you're using it to save UIColors in NSDefaults on a single device. This solution will not work if the value may be encoded on one platform and decoded on a different one.
Note: I did not extensively test stringValue, but the format specifier is %f for 64-bit floating-point numbers (double) and the docs do not specify that this is different for 32-bit.