CGColorRef is crashing

I had a malfunction in my code, and I traced it until the line crashed while transmitting 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);

NSLog returns a failure. What is wrong with them?

EDIT - where is it crashing:

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGFloat locations[] = { 0.0, 1.0 };
NSArray *colors = [NSArray arrayWithObjects:(__bridge_transfer id)startColor, (__bridge_transfer id)endColor, nil];
+5
source share
1 answer

ARC. ARC. ARC. UIColor-> CGCOlor is one of the big errors of ARC ...

See here a deep dive:

http://weblog.bignerdranch.com/?p=296

And I wrote some general guidelines for ARC (including your problem) here:

http://amattn.com/2011/12/07/arc_best_practices.html

+13
source

All Articles