Skip to content

Instantly share code, notes, and snippets.

View d4r1091's full-sized avatar

Dario Carlomagno d4r1091

View GitHub Profile
@matsuda
matsuda / Deallocation.swift
Last active September 15, 2020 09:37
Swizzling in Swift
// MARK: - check dealloc
private extension UIViewController {
// Add below to _swizzled_viewDidDisappear(_:)
func _checkDeallocation(afterDelay delay: TimeInterval = 1.5) {
if isMovingFromParent || rootParent.isBeingDismissed {
let disappearance = isMovingFromParent ? "removed from its parent" : "dismissed"
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in
guard let self = self else { return }
let message = "\(String(describing: type(of: self))) not deallocated after being \(disappearance)"

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a