1

I have ARC enabled and I'm trying to do:

CGColorRef outerColor = (id)[UIColor colorWithWhite:1.0 alpha:1.0].CGColor;

My attempted cast results in the error:

Implicit conversion of an Objective-C pointer to 'CGColorRef' (aka 'struct CGColor *') is disallowed with ARC

I've tried a number of things, but I don't know how to complete this cast.

halfer
  • 19,824
  • 17
  • 99
  • 186
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284

2 Answers2

3

You need to bridge the cast so ARC can understand what you are doing and how to react to it. Check the accepted answer of this question out: ARC and bridged cast

Community
  • 1
  • 1
Johannes Lumpe
  • 1,762
  • 13
  • 16
1

(Posted answer on behalf of the OP).

I am adding outerColor to an array so I did this:

CAGradientLayer *maskLayer = [CAGradientLayer layer];

CGColorRef outerColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor;
CGColorRef innerColor = [UIColor colorWithWhite:1.0 alpha:0.0].CGColor;

maskLayer.colors = [NSArray arrayWithObjects:(__bridge id)outerColor, 
                    (__bridge id)innerColor, (__bridge id)innerColor, (__bridge id)outerColor, nil];
halfer
  • 19,824
  • 17
  • 99
  • 186