Reputation: 4768
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 :)
Upvotes: 7
Views: 3361
Reputation: 6009
Update for Swift 4.0:
This is no longer needed in current versions of Swift.
CGColorSpaceRelease(colorSpace)
This line of code now gives the following message:
'CGColorSpaceRelease' is unavailable: Core Foundation objects are automatically memory managed
Upvotes: 10
Reputation: 14834
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).
Upvotes: 11
Reputation: 5891
Yes, I believe so, even under ARC.
You need to call CGColorSpaceRelease
as per the documentation CGColorSpace Documentation.
Upvotes: 3