Hi all-

I've got a category on NSColor to return a CGColor value.  Source looks like 
this:

- (CGColorRef)CGColor
{
    NSColor *colorRGB = [self 
colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
    CGFloat components[4];
    [colorRGB getRed:&components[0] green:&components[1] blue:&components[2] 
alpha:&components[3]];
    CGColorSpaceRef theColorSpace = 
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    CGColorRef theColor = CGColorCreate(theColorSpace, components);
    CGColorSpaceRelease(theColorSpace);
    return theColor;
}

My issue is with the final line: the CGColor has a retain count of 1, as it was 
made with a "Create" function.  Following Cocoa convention, I'd want to cast 
the return value and autorelease it, but the autorelease call is not allowed 
under ARC.  Xcode is doing its best to help me figure out how to return the 
value, but the only thing I can get it to not squeak about is this:

return (__bridge_retained CGColorRef)(__bridge_transfer id)theColor;

which does not seem reasonable to me.  Can anyone suggest the proper syntax to 
return an "autoreleased" CGColorRef from this function? 

Thanks!

John


John Pannell
http://www.positivespinmedia.com_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to