¿Los auriculares están enchufados? ios 7

Desarrollar una aplicación para un iPhone con archivos de audio que también deben escucharse a través de los auriculares.

¿Cómo verifico si los auriculares no están enchufados para poder decirle al usuario que los conecte?

Tengo el siguiente código de otro hilo, pero el método audioSessionGetProperty está en desuso. Alguien sabe cómo alterar el siguiente código para hacer que esto funcione O tener su propio código / solución.

Gracias.

- (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,
                                              &routeSize,
                                              &route);

    /* Known values of route:
     * "Headset"
     * "Headphone"
     * "Speaker"
     * "SpeakerAndMicrophone"
     * "HeadphonesAndMicrophone"
     * "HeadsetInOut"
     * "ReceiverAndMicrophone"
     * "Lineout"
     */

    if (!error && (route != NULL)) {

        NSString* routeStr = (__bridge NSString*)route;

        NSRange headphoneRange = [routeStr rangeOfString : @"Head"];

        if (headphoneRange.location != NSNotFound) return YES;

    }

    return NO;
}

Respuestas a la pregunta(7)

Su respuesta a la pregunta