Swift: how to log out retain count of objects?

sirab333 picture sirab333 · Mar 10, 2015 · Viewed 16.9k times · Source

Is there a way to quickly log out the retain count of objects to Xcode's Console? If not, what's the next best alternative?

Answer

Tritmm picture Tritmm · Jun 24, 2016

using CFGetRetainCount function

Example:

// `CFGetRetainCount` is only available in the `Foundation` module
import Foundation

print(CFGetRetainCount(object))

Read more here : https://developer.apple.com/reference/corefoundation/1521288-cfgetretaincount

hope helpful