title: why adding an oberver to remove it right after
body: <p>I recently looked into some swift code and I found this: adding the observer and then removing it right after. What's the logic behind that?</p>
  
  <pre><code>override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(animated)
      NSNotificationCenter.defaultCenter().addObserver(self, selector: "displayPushMessage:", name: "displayMessage", object: nil)
  
  }
  
  //adding the observer and removing it right after whhy?? where is the logic
  
  override func viewDidDisappear(animated: Bool) {
      super.viewDidDisappear(animated)
      NSNotificationCenter.defaultCenter().removeObserver(self, name: "displayMessage", object: nil)
  }
  
  func displayPushMessage (notification:NSNotification) {
  </code></pre>