From 82004a01ae878f95cbb53043080c54289583f69c Mon Sep 17 00:00:00 2001 From: S4cha Date: Tue, 21 Aug 2018 09:55:14 +0200 Subject: [PATCH] Refactors to avoid force unwrapping --- .../KeyboardLayoutGuide/Keyboard+LayoutGuide.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/KeyboardLayoutGuide/KeyboardLayoutGuide/Keyboard+LayoutGuide.swift b/KeyboardLayoutGuide/KeyboardLayoutGuide/Keyboard+LayoutGuide.swift index a946980..2f598d4 100644 --- a/KeyboardLayoutGuide/KeyboardLayoutGuide/Keyboard+LayoutGuide.swift +++ b/KeyboardLayoutGuide/KeyboardLayoutGuide/Keyboard+LayoutGuide.swift @@ -118,7 +118,8 @@ extension Notification { } // Weirdly enough UIKeyboardFrameEndUserInfoKey doesn't have the same behaviour // in ios 10 or iOS 11 so we can't rely on v.cgRectValue.width - return (UIApplication.shared.keyWindow?.bounds.height)! - v.cgRectValue.minY + let screenHeight = UIApplication.shared.keyWindow?.bounds.height ?? UIScreen.main.bounds.height + return screenHeight - v.cgRectValue.minY } }