Just updated to Xcode Beta 4, and noticed the following compiler error with my code below:
var path = CGPathCreateMutable()
...
CGPathRelease(path)
The Working with Cocoa Data Types section of Using Swift with Cocoa and Objective-C says (emphasis mine):
Core Foundation objects returned from annotated APIs are automatically memory managed in Swift—you do not need to invoke the
CFRetain,CFRelease, orCFAutoreleasefunctions yourself. If you return Core Foundation objects from your own C functions and Objective-C methods, annotate them with eitherCF_RETURNS_RETAINEDorCF_RETURNS_NOT_RETAINED.…
When Swift imports APIs that have not been annotated, the compiler cannot automatically memory manage the returned Core Foundation objects. Swift wraps these returned Core Foundation objects in an
Unmanaged<T>structure.
So yes, unless you have an Unmanaged struct, this is correct and you don't have to worry about manually releasing the object.