ARC releases UIColor prematurely
||Date Originated:||June 21st, 2012|
When assigning a UIColor's CGColor to a CGColorRef for later use then ARC discards the UIColor too early when running on device.
Steps to Reproduce:
Run the attached sample project.
App should run equally well on Simulator and Device. ARC should not release the UIColor before the end of the scope.
App runs ok on Simulator, but crashes on Device with EXC_BAD_ACCESS.
This was working fine before using it in a project without ARC since the code in question does not use NSObjects for anything except to create the two CGColorRefs.
A workaround is to save the UIColor in an IVAR to establish a strong reference. When doing this the exception no longer occurs. Another workaround apparently is to immediately CGColorRetain the CGColor.
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!