Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use __bridge for ARC correctly
    primarykey
    data
    text
    <p>I changed the code shown below into ARC compatible.</p> <p>I just changed it as Xcode suggested, and it doesn't show error on Xcode. But the code crushes once the event happens. Does anybody have an idea to fix this?</p> <p>I'm not sure if this crush happens because of acapela SDK, or not.</p> <p><strong>This is non ARC code, it works fine.</strong></p> <pre><code>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]; } } </code></pre> <p><strong>This is ARC compatible, but it crushes on [anAcapelaSpeech setActive:NO];.</strong></p> <pre><code>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]; } } </code></pre> <p><strong>Additional info.</strong> I'm using Acapela audio SDK, audio interruption code is shown on the 9.Interruptions of this PDF. <a href="http://www.ecometrixem.com/cms-assets/documents/44729-919017.acapela-for-iphone.pdf" rel="nofollow noreferrer">http://www.ecometrixem.com/cms-assets/documents/44729-919017.acapela-for-iphone.pdf</a></p> <p>This is the screenshot for the crush. <img src="https://i.stack.imgur.com/h1C1b.png" alt="enter image description here"></p> <p><strong>SOLVED</strong> This code works, thanks.</p> <pre><code>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]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload