Ir al contenido

Observer Never Removed (ARCH9033)

Esta página aún no está disponible en tu idioma.

Key swift.async.observer-never-removed · Severity warning · Category async

Flags NotificationCenter observers, KVO observers and timers added by a class that never removes / invalidates them.

NotificationCenter.default.addObserver(self, selector: #selector(update), name: .x, object: nil)
deinit { NotificationCenter.default.removeObserver(self) }

Remove the observer (or invalidate the timer) in deinit, or keep the token and cancel it.