title: Are headphones plugged in? iOS7
body: <p>Developing an app for an iPhone with audio files that need to be listened too through headphones.</p>
  
  <p>How do I check if headphones aren't plugged in so I can tell the user to plug in headphones.</p>
  
  <p>I have the following code from another thread but the audioSessionGetProperty method is deprecated. Anyone know how to alter the following code to make this work OR have there own code/solution. </p>
  
  <p>Thanks.</p>
  
  <pre><code>- (BOOL)isHeadsetPluggedIn {
      UInt32 routeSize = sizeof (CFStringRef);
      CFStringRef route;
  
  
      //Maybe changing it to something like the following would work for iOS7?
      //AVAudioSession* session = [AVAudioSession sharedInstance];
      //OSStatus error = [session setCategory:kAudioSessionProperty_AudioRoute...?
  
  
      //the line below is whats giving me the warning
      OSStatus error = AudioSessionGetProperty (kAudioSessionProperty_AudioRoute,
                                                &amp;routeSize,
                                                &amp;route);
  
      /* Known values of route:
       * "Headset"
       * "Headphone"
       * "Speaker"
       * "SpeakerAndMicrophone"
       * "HeadphonesAndMicrophone"
       * "HeadsetInOut"
       * "ReceiverAndMicrophone"
       * "Lineout"
       */
  
      if (!error &amp;&amp; (route != NULL)) {
  
          NSString* routeStr = (__bridge NSString*)route;
  
          NSRange headphoneRange = [routeStr rangeOfString : @"Head"];
  
          if (headphoneRange.location != NSNotFound) return YES;
  
      }
  
      return NO;
  }
  </code></pre>