Reputation: 16051
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];
Upvotes: 5
Views: 1701
Reputation: 10065
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
Upvotes: 13