title: How do I compare an NSNumber to a swift enumeration value?
body: <p>I'm trying to do a simple comparison of a value received via an NSNotification, and an enumeration value. I have something that works, but I can't believe that this is the right way to be doing this. Basically the solution I ended up with was converting the NSNumber to an Int, and also getting the enum value's rawValue, wrapping it in an NSNumber and then getting the integerValue of that.</p>
  
  <p>Everything else I tried resulted in compiler errors about not being able to convert between Uint 8 and Int or something similar.</p>
  
  <pre><code>    observer = NSNotificationCenter.defaultCenter().addObserverForName(AVAudioSessionRouteChangeNotification, object: nil, queue: mainQueue) { notification in
  
          println(AVAudioSessionRouteChangeReason.NewDeviceAvailable.toRaw())
  
          if let reason = notification.userInfo[AVAudioSessionRouteChangeReasonKey!] as? NSNumber  {
              if (reason.integerValue == NSNumber(unsignedLong:AVAudioSessionRouteChangeReason.NewDeviceAvailable.toRaw()).integerValue) {
                  self.headphoneJackedIn = true;
              } else if (reason.integerValue == NSNumber(unsignedLong:AVAudioSessionRouteChangeReason.OldDeviceUnavailable.toRaw()).integerValue) {
                  self.headphoneJackedIn = false;
              }
              self.updateHeadphoneJackLabel()
          }
      }
  </code></pre>