objective-ciospointersautomatic-ref-countingcgcolor

ios casting objc pointer to struct cgcolorref


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.


Solution

  • 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