I\'ve created a context using CGBitmapContextCreate. Do I need to release it using CGContextRelease? I know the answer is yes in Objective-C, but how about in Swift?
No, you don't need to call CGContextRelease
. In fact, trying to gives you this error:
'CGContextRelease' is unavailable: Core Foundation objects are automatically memory managed
CGContext
instances are automatically memory managed in Swift. You can tell from the function signature:
func CGBitmapContextCreate(/* several parameters */) -> CGContext!
A return value you would need to release yourself would look like:
func CGBitmapContextCreate(/* several parameters */) -> Unmanaged!