Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Releasing objects in Swift

Tags:

ios

swift

I am new to Swift and am wondering if anyone can anyone help confirm my understanding with releasing objects in Apple's Swift?

The documentation for CGPathCreateWithRect() described here states that the return value is

"A new, immutable path. You are responsible for releasing this object."

When is says "you are responsible" is it as simple as saying that when you no longer hold a reference the garbage collector will delete the object? I.e. you are responsible for managing the references? In which case - isn't that obvious? If not - what does it mean?

Thanks

Bryon

like image 726
Bryon Avatar asked Dec 19 '22 20:12

Bryon


1 Answers

You are responsible only when using Objective-C

From the Swift documentation

Memory Managed Objects

Core Foundation objects returned from annotated APIs are automatically memory managed in Swift—you do not need to invoke the CFRetain, CFRelease, or CFAutorelease functions yourself.

like image 105
vadian Avatar answered Dec 28 '22 23:12

vadian