CGRectMakeWithDictionaryRepresentation

Originator:oliver.drobnik
Number:rdar://12358120 Date Originated:September 24, 2012
Status:Open Resolved:
Product:iPhone SDK Product Version:6.0 (10A403)
Classification:Data Loss Reproducible:Always
 
Summary:

CGRectMakeWithDictionaryRepresentation on iOS fails to parse certain float values from a plist saved on Mac. 

This bug is a very rare occurrence because it only appears if you have non-integer values encoded in a property list, modify this on Mac (e.g. Xcode) and then try to parse it again on iOS.


Steps to Reproduce:

1) on iOS: create a CGRect (123.2112731933594,123.2112731933594,123.2112731933594,123.2112731933594)
2) save it into a file, notice that the value will be 123.21127319335938 instead.
3) open it with Xcode plist editor
4) save it, the values in the file will change to be 123.2112731933594
5) load the dictionary from disk, try to extract the CGRect by CGRectMakeWithDictionaryRepresentation


Expected Results:

the CGRect values should be 123.21127319335938 or 123.2112731933594


Actual Results:

only origin gets a concatenated value, all other values are zero: {{123.211, 0}, {0, 0}}, return value of the function is FALSE which means an error occurred.


Regression:

n/a


Notes:

A sample project is provided that demonstrates the issue in the form of unit tests:
- testOriginalPlist parses an iOS generated plist without issue
- testMofiedPlistByXCode parses a plist modified by Xcode showing the failure
- testParseRealString shows that the problematic representation works with float/doubleValue
- (void)testRectMake demonstrate how modifying a fresh encoded number fails if the 5938 (iOS) is changed to 594 (Mac)

http://www.cocoanetics.com/files/NSDictionaryCGRectParsing.zip

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!