Do I need to release CGColorSpaceRef under ARC?

automatic-ref-counting, core-graphics, ios

Solution

Yes. According to Apple's doc: Because CGColorSpaceRelease function is equivalent to CFRelease, except that it does not cause an error if the cs parameter is NULL. And if you create, copy, or explicitly retain a Core Foundation object, you are responsible for releasing it when you no longer need it (see Memory Management Programming Guide for Core Foundation).

Problem

Let's say I have this piece of code: ``` CGColorSpaceRef colorSpaceRGB = CGColorSpaceCreateDeviceRGB(); CGContextSetStrokeColorSpace(context, colorSpaceRGB); CGContextSetFillColorSpace(context, colorSpaceRGB); ``` After that I do some drawing. When I'm done, do I need to manually release `colorSpaceRGB` if I'm using ARC? Like this: ``` CGColorSpaceRelease(colorSpaceRGB); ``` Or I don't need to do anything? Thanks :)

Original source

Related problems