title: Convert method that returns an autoreleased CGColor to ARC
body: <p>I'm in the process of converting my project to using ARC. I have a category on NSColor with a method that returns an autoreleased CGColor representation:</p>
  
  <pre><code>@implementation NSColor (MyCategory)
  
  - (CGColorRef)CGColor
  {
      NSColor *colorRGB = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
      CGFloat components[4];
      [colorRGB getRed:&amp;components[0]
                 green:&amp;components[1]
                  blue:&amp;components[2]
                 alpha:&amp;components[3]];
      CGColorSpaceRef space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
      CGColorRef theColor = CGColorCreate(space, components);
      CGColorSpaceRelease(space);
      return (CGColorRef)[(id)theColor autorelease];
  }
  
  @end
  </code></pre>
  
  <p>What is the correct way to do this with ARC? I don't want to return a retained CGColor.</p>
  
  <p>The ARC converter in XCode suggest using</p>
  
  <pre><code>return (CGColorRef)[(__bridge id)theColor autorelease];
  </code></pre>
  
  <p>but that results in the following error message:</p>
  
  <blockquote>
    <p>[rewriter] it is not safe to cast to 'CGColorRef' the result of
    'autorelease' message; a __bridge cast may result in a pointer to a
    destroyed object and a __bridge_retained may leak the object</p>
  </blockquote>