Skip to content

Commit e847bd5

Browse files
author
Jakob Mygind
committed
Remove force unwraps
1 parent 24d3724 commit e847bd5

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Rye/Rye/RyePresentation.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import UIKit
1313
public extension RyeViewController {
1414
func show() {
1515

16-
switch self.alertType! {
16+
switch self.alertType {
1717
case .toast:
1818
// create a new UIWindow
1919
let window = UIWindow(frame: UIScreen.main.bounds)
@@ -59,7 +59,7 @@ public extension RyeViewController {
5959

6060
guard let self = self else { return }
6161

62-
switch self.alertType! {
62+
switch self.alertType {
6363
case .toast:
6464
// remove the UIWindow
6565
self.window?.isHidden = true
@@ -103,7 +103,7 @@ public extension RyeViewController {
103103
let safeArea = getSafeAreaSpacing()
104104

105105
// update RyeView bottom constraint to position it on screen
106-
switch position! {
106+
switch position {
107107
case .bottom(let inset):
108108
return -safeArea - inset
109109
case .top(let inset):
@@ -137,7 +137,7 @@ public extension RyeViewController {
137137
// update RyeView bottom constraint to position it off screen
138138

139139
func getRyeViewPositionConstant() -> CGFloat {
140-
switch position! {
140+
switch position {
141141
case .bottom:
142142
return ryeView.frame.height
143143
case .top:

Rye/Rye/RyeViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class RyeViewController: UIViewController {
2929

3030
// all presentation logic is done using parentView
3131
var parentView: UIView {
32-
switch alertType! {
32+
switch alertType {
3333
case .snackBar:
3434
if var topController = UIApplication.shared.keyWindow?.rootViewController {
3535
while let presentedViewController = topController.presentedViewController {
@@ -50,10 +50,10 @@ public class RyeViewController: UIViewController {
5050
return keyWindow
5151
}
5252
}
53-
var alertType: Rye.AlertType!
54-
var viewType: Rye.ViewType!
53+
var alertType: Rye.AlertType
54+
var viewType: Rye.ViewType
5555
var timeAlive: TimeInterval?
56-
var position: Rye.Position!
56+
var position: Rye.Position
5757
var animationDuration: TimeInterval!
5858
var animationType: Rye.AnimationType!
5959

@@ -132,7 +132,7 @@ public class RyeViewController: UIViewController {
132132
ryeView.widthAnchor.constraint(lessThanOrEqualTo: parentView.widthAnchor, constant: -16).isActive = true
133133

134134
// setup constraint
135-
switch position! {
135+
switch position {
136136
case .bottom:
137137
ryeViewPositionConstraint = ryeView.bottomAnchor.constraint(equalTo: parentView.bottomAnchor)
138138
case .top:
@@ -146,7 +146,7 @@ public class RyeViewController: UIViewController {
146146
ryeView.layoutIfNeeded()
147147

148148
// update RyeView bottom constraint constat to position it outside of the application's UIWindow
149-
switch position! {
149+
switch position {
150150
case .bottom:
151151
ryeViewPositionConstraint.constant = ryeView.frame.height
152152
case .top:

0 commit comments

Comments
 (0)