memory-managementswiftautomatic-ref-counting

Swift with no ARC


Is it possible to write apps using manual memory management (instead of automatic reference counting) using Swift?

Can I call retain and release using Swift?


Solution

  • You can call retain and release on Unmanaged<T> values. Unmanaged is basically object pointers that are outside of ARC management. But you would have to convert to managed pointers to interact with Cocoa APIs.

    But you wouldn't want to do this unless in exceptional circumstances. And a project that isn't converted to ARC isn't such a situation.