iOS/Error
[iOS Error] Terminating app due to uncaught exception 'NSInternalInconsistencyException'
Peppo
2021. 10. 17. 17:12
728x90
문제
카메라 기능 작업중, 사용자가 카메라 접근권한을 허용하지 않을시 alert창을 띄워져야하는데
콘솔에 아래와 같은 에러가 뜨면서 앱이 꺼져버렸다.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.'
에러내용을 보면 layout 엔진은 main thread에서 접근이 되었다면 background thread에서 수행되어서는 안된다.
위 내용을 바탕으로 에러가 났던 부분을 DispatchQueue.main.async로 감싸주었더니 고쳐졌다.
DispatchQueue.main.async{
// code
}
728x90