Removed AnyObject protocol inheritance
Dysprosium is part of the E-sites iOS Suite.
Deallocation helper for runtime objects.This library is pure for debugging purposes.
package.swift dependency:
.package(url: "https://github.com/e-sites/dysprosium.git", from: "6.0.0"),
and to your application/library target, add "Dysprosium" to your dependencies, e.g. like this:
"Dysprosium"
dependencies
.target(name: "BestExampleApp", dependencies: ["Dysprosium", "DysprosiumLogger"]),
// AppDelegate func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // ... Dysprosium.shared.onDealloc { objects in print("[INFO] Deallocated objects: \(objects)") } Dysprosium.shared.onExpectedDeallocation { object, message in print("[WARNING] Expected deallocation of \(object): \(message)") } }
This way you can easily see what objects have been deallocated.
import Dysprosium class SomeObject: DysprosiumCompatible { // ... deinit { deallocated() } }
Most of the time when a UIViewController disappears it should be deallocated.With expectDeallocation() you can monitor if it actually is deallocated.
UIViewController
expectDeallocation()
import Dysprosium class SomeViewController: UIViewController, DysprosiumCompatible { // ... override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) expectDeallocation() } deinit { deallocated() } }
If an object gets deallocated, but you need to check that an underlying object is deallocated as well:
import Dysprosium class SomeObject: DysprosiumCompatible { // ... let relatedObject: SomeObject deinit { relatedObject.expectDeallocation() deallocated() } }
Disable Dysprosium like this:
Dysprosium.shared.isEnabled = false
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Dysprosium is part of the E-sites iOS Suite.
Deallocation helper for runtime objects.
This library is pure for debugging purposes.
Installation
Swift PM
package.swift dependency:
and to your application/library target, add
"Dysprosium"
to yourdependencies
, e.g. like this:Implementation
Log deallocations
This way you can easily see what objects have been deallocated.
Expect deallocations
UIViewController
Most of the time when a
UIViewController
disappears it should be deallocated.With
expectDeallocation()
you can monitor if it actually is deallocated.Related objects
If an object gets deallocated, but you need to check that an underlying object is deallocated as well:
Release builds
Disable Dysprosium like this: