0

I have a detecting permission code for firtly microphone and then speechrecognation for open new view. But the code below created error like " This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes."

Could anyone have any idea?

 if (@available(iOS 10.0, *)) {
    [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
        if (granted) {
         //   [self detechUserSpeechPermission];
       //     [self configureSpeechToTextView];
            [SFSpeechRecognizer requestAuthorization:^(SFSpeechRecognizerAuthorizationStatus status) {
                switch (status) {
                    case SFSpeechRecognizerAuthorizationStatusAuthorized:
                        [self configureSpeechToTextView];
                        break;
                    case SFSpeechRecognizerAuthorizationStatusDenied:
                        [self warnUserForSpeechPermission];
                        break;
                    case SFSpeechRecognizerAuthorizationStatusNotDetermined:
                        [self warnUserForSpeechPermission];
                        break;
                    case SFSpeechRecognizerAuthorizationStatusRestricted:
                        [self warnUserForSpeechPermission];
                        break;
                    default: break;
                } }];
        }
        else {
            [self warnUserForMicrophonePermission];
        }
    }];
} else {
    NSLog(@"low ios version");
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • I doubt your error has anything to do with the code you're showing us, since it has nothing to do with AutoLayout at all. – JillevdW Mar 01 '18 at 13:53

1 Answers1

0

try to call methods at main thread like below code:

dispatch_async(dispatch_get_main_queue(), ^{
  [self configureSpeechToTextView];
});
Moayad Al kouz
  • 1,342
  • 1
  • 9
  • 19