Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to release CGColorSpaceRef under ARC?

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 :)

like image 798
xx77aBs Avatar asked Jun 24 '12 16:06

xx77aBs


1 Answers

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).

like image 190
user523234 Avatar answered Oct 14 '22 11:10

user523234