0

I have a native iOS project in which we have integrated react native. Here we have a screen A in native iOS(swift) and screen B in React-native. When user is in screen A clicks on component and navigated to screen B. Inside screen B then user selects a option and passes that value to brigde between the two parts using NativeModules. After that screen B gets dismissed and user is again able to see the screen A. The value which is passed through bridge can be accessed inside a function in screen A view controller, but when trying to set that value to UITextField getting error Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

Expecting to set the value which is received from screen B in screen A gets saved in UITextField to be utilised further

  • Please share some code. – tomerpacific Mar 28 '22 at 08:47
  • See https://stackoverflow.com/questions/32170456/what-does-fatal-error-unexpectedly-found-nil-while-unwrapping-an-optional-valu but you have probably created your view controller without using a storyboard – Paulw11 Mar 28 '22 at 09:15

1 Answers1

0
Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

This means that you tried to use an object which is nil. E.g. you had a textField object (type of UITextField) and you tried to use:

textField!.text = "Some text"

Your textField is not yet initialized. Without code it's hard to say what's wrong but either you should have initilaized textField somewhere before:

textField = UITextField()

Or you should safely unwrap the field and try to set the value - if it's nil it still won't be set.

textField?.text = "Some text"
zdtorok
  • 594
  • 1
  • 7
  • 21