How to use __bridge for ARC

I changed the code shown below to ARC compatible.

I just changed it as suggested by Xcode, and it does not show an error in Xcode. But the code will crush as soon as the event occurs. Anyone have an idea to fix this?

I'm not sure if this distribution is due to the acapela SDK or not.

This is not an ARC code, it works great.

void MyInterruptionListener(void *inClientData, UInt32 inInterruptionState) {

    AcapelaSpeech* anAcapelaSpeech = *(AcapelaSpeech**)inClientData;

    if (inInterruptionState == kAudioSessionBeginInterruption) {

        [anAcapelaSpeech setActive:NO];
        status = AudioSessionSetActive(NO);
    }
    if (inInterruptionState == kAudioSessionEndInterruption) {

        status = AudioSessionSetActive(YES);
        [anAcapelaSpeech setActive:YES];
    }
}

This is compatible with ARC, but it is suppressed by [anAcapelaSpeech setActive: NO] ;.

void MyInterruptionListener(void *inClientData, UInt32 inInterruptionState) {

    AcapelaSpeech* anAcapelaSpeech = (__bridge_transfer AcapelaSpeech*)inClientData;

    if (inInterruptionState == kAudioSessionBeginInterruption) {

        [anAcapelaSpeech setActive:NO];
        AudioSessionSetActive(NO);
    }
    if (inInterruptionState == kAudioSessionEndInterruption) {

        AudioSessionSetActive(YES);
        [anAcapelaSpeech setActive:YES];
    }
}

Additional Information. I am using the Acapela audio SDK audio channel, the audio interrupt code is shown at 9.Interruptions of this PDF. http://www.ecometrixem.com/cms-assets/documents/44729-919017.acapela-for-iphone.pdf

This is a screenshot for crushing. enter image description here

solvable This code works, thanks.

void MyInterruptionListener(void *inClientData, UInt32 inInterruptionState) {

    AcapelaSpeech *anAcapelaSpeech = (__bridge id) (*(void **) inClientData);

    if (inInterruptionState == kAudioSessionBeginInterruption) {

        [anAcapelaSpeech setActive:NO];
        AudioSessionSetActive(NO);
    }
    if (inInterruptionState == kAudioSessionEndInterruption) {

        AudioSessionSetActive(YES);
        [anAcapelaSpeech setActive:YES];
    }
}
+5
1

- :

id asObject = (__bridge id) (*(void **) ptr);
+6

All Articles