== Why is this an issue?

Classes can register themselves to receive notifications using ``++NotificationCenter.add++``. Having done so, it seems suspicious that a class would opt to stop receiving notifications before de-initialization. For that reason, this rule raises an issue when ``++NotificationCenter.default.removeObserver(self)++`` is called anywhere but in ``++deinit++``


=== Noncompliant code example

[source,swift]
----
class MyClass {
  func doTheThing() {
    //...
    NotificationCenter.default.removeObserver(self)  // Noncompliant
  }
}
----


=== Compliant solution

[source,swift]
----
class MyClass {
  func doTheThing() {
    //...
  }

  func deinit() {
    NotificationCenter.default.removeObserver(self)
  }
}
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Move this call to (a|the) "deinit" method.


=== Highlighting

``++removeObserver(self)++``


endif::env-github,rspecator-view[]
