algolia / voice-overlay-ios

🗣 An overlay that gets your user’s voice permission and input as text in a customizable UI
https://alg.li/voice
MIT License
545 stars 62 forks source link

Change Locale error #12

Closed tamdragle closed 5 years ago

tamdragle commented 5 years ago

When I change change locale like so:

var voiceOverlayController: VoiceOverlayController {
    let recordableHandler = {
        return SpeechController(locale: Locale(identifier: "en_US"))
    }
    return VoiceOverlayController(speechControllerHandler: recordableHandler)
 }

I get a crash when run:

inputViewController.dismissHandler = { [unowned self] (retry) in
          self.inputViewController = nil
          if retry {
            self.showRecordingScreen(view)
          }
        }

Fatal error: Attempted to read an unowned reference but the object was already deallocated2019-01->10 10:09:32.479917+0700 hoaanhdao[2018:372531] Fatal error: Attempted to read an unowned >reference but the object was already deallocated (lldb)

spinach commented 5 years ago

Hi @tamdragle - I think this is probably related to this issue here https://github.com/algolia/voice-overlay-ios/issues/4#issuecomment-430298541. Basically you're losing reference to the voice controller. You need to keep a strong reference to it.

Feel free to re-open the issue if it doesn't solve your issue

tamdragle commented 5 years ago

Hi @spinach Thank you!