title: Device Rotation Notification is not working as expected iOS Swift
body: <pre><code>    func shouldirotate(){
  
      var whichwaywhere: String {
  
          if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft {
              return "left"
          }
          if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeRight {
              return "right"
          }
          if UIDevice.currentDevice().orientation == UIDeviceOrientation.PortraitUpsideDown {
              return "down"
          }
          return "I don't Care"
      }
      println(whichwaywhere)
  }
  </code></pre>
  
  <p>when I create a function that continuously checks itself, (attaching shouldirotate to a NSTimer) I can get the orientation checked. How could I tell the function to run when UIDeviceOrientationDidChangeNotification activates?</p>
  
  <p>To get UIDeviceOrientationDidChangeNotification running I have a variable:</p>
  
  <pre><code>var rotatenote: Bool = UIDevice.currentDevice().generatesDeviceOrientationNotifications
  </code></pre>
  
  <p>and in the ViewDidLoad override I have:</p>
  
  <pre><code>override func viewDidLoad() {
      UIDevice.currentDevice().beginGeneratingDeviceOrientationNotifications()
      rotatenote = true
  }
  </code></pre>
  
  <p>Is this the correct way to use and declare this property?  how can I get the function to run off of DeviceOrientationNotification?</p>
  
  <p>P.S.: I have rotatenote = true in the ViewDidLoad because if I try to attach it to the variable declaration like usual, it says "cannot assign to the result of this expression." See Below</p>
  
  <pre><code>var rotatenote: Bool = UIDevice.currentDevice().generatesDeviceOrientationNotifications = true
  </code></pre>