mnbayan / AutocompleteTextfieldSwift

Simple and straightforward sublass of UITextfield to manage string suggestions
MIT License
290 stars 66 forks source link

fatal error: unexpectedly found nil while unwrapping an Optional value #40

Open dipenshah210 opened 8 years ago

dipenshah210 commented 8 years ago

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!)

Nidhee commented 8 years ago

Same issue I am having. Any solution to this ?

Nidhee commented 8 years ago

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.

anand-y commented 7 years ago

@Nidhee Thanks