I've had a crash in my code, and I've tracked it all the way back to a line crashing when being passed 2 CGColorRefs. Here are the objects:
CGColorRef startColor = [[UIColor colorWithWhite:0.92 alpha:1.0]CGColor];
CGColorRef endColor = [[UIColor colorWithWhite:0.94 alpha:1.0]CGColor];
NSLog(@"start: %@ end: %@", startColor, endColor);
The NSLog returns a crash. What's wrong with them?
EDIT - where it's crashing:
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGFloat locations[] = { 0.0, 1.0 };
NSArray *colors = [NSArray arrayWithObjects:(__bridge_transfer id)startColor, (__bridge_transfer id)endColor, nil];
ARC. ARC. ARC. UIColor->CGCOlor is one of ARC's big gotchas...
See a deep dive here:
http://weblog.bignerdranch.com/?p=296
And I wrote up some general best practices for ARC (including your problem) here:
http://amattn.com/2011/12/07/arc_best_practices.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With