mnbayan/AutocompleteTextfieldSwift

fatal error: unexpectedly found nil while unwrapping an Optional value

Opened this issue · 3 comments

Hey, I tried using your code for my application. Unfortunately when I click on button and the viewcontroller appears modally with navigation controller embedded in, it show the following error in AutocompleteTextfield.

fatal error: unexpectedly found nil while unwrapping an Optional value

The error occurs at following function:

public override func awakeFromNib() {
super.awakeFromNib()
commonInit()
setupAutocompleteTable(superview!)

Same issue I am having. Any solution to this ?

I tried to add one if condition in willMoveToSuperview()
public override func willMoveToSuperview(newSuperview: UIView?) { super.willMoveToSuperview(newSuperview) commonInit() if let newSuperviews = newSuperview { setupAutocompleteTable(newSuperviews) } }

And it worked with me. it was not crashing.

@Nidhee Thanks