현재 뷰가 아닌곳에서 alert띄우려고 하고있어서, "whose view is not in the window hierarchy"라고 알려줌
왜냐 appDelegate나 sceneDelegate는 뷰가 아니라서 띄우는거 자체가 불가능하다
그래서 present만 메인의 비동기처리로 보내 현재 씬의 최상단뷰에서 띄워줌
DispatchQueue.main.async {
guard let viewController = (UIApplication.shared.connectedScenes.first?.delegate as?
SceneDelegate)?.window?.rootViewController?.topViewController else { return }
viewController.present(alert, animated: true)
}
'짤막 TlL' 카테고리의 다른 글
Self vs self (2) | 2022.10.28 |
---|---|
타입캐스팅 TIL (0) | 2022.08.18 |
CLGeocoder (0) | 2022.08.17 |
toggle() (0) | 2022.08.15 |
킹피셔 말고 이미지에 url담기 (0) | 2022.08.09 |