Skip to content

Commit

Permalink
fix: avoid usage of forced unwrapping (#95)
Browse files Browse the repository at this point in the history
## 📜 Description

Added optional chaining instead of forced unwrapping. Fixes crash
described in
#93

## 💡 Motivation and Context

In fact it's not a fix and is more avoiding NPE rather than a full fix.
But anyway, missing animation is better, than a crash of application
🤷‍♂️

## 📢 Changelog

### iOS
- avoid usage of forced unwrapping

## 🤔 How Has This Been Tested?

Tested locally on:
- iPhone 13 Pro (iOS 15.0);

## 📝 Checklist

- [x] CI successfully passed
  • Loading branch information
kirillzyusko authored Nov 4, 2022
1 parent 198ede2 commit 9a56d79
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ios/KeyboardMovementObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ public class KeyboardMovementObserver: NSObject {
return
}

var keyboardFrameY = keyboardView!.layer.presentation()!.frame.origin.y
var keyboardWindowH = keyboardView!.window!.bounds.size.height
var keyboardFrameY = keyboardView?.layer.presentation()?.frame.origin.y ?? 0
var keyboardWindowH = keyboardView?.window?.bounds.size.height ?? 0
var keyboardPosition = keyboardWindowH - keyboardFrameY

if keyboardPosition == prevKeyboardPosition || keyboardFrameY == 0 {
Expand Down

0 comments on commit 9a56d79

Please sign in to comment.