darkterbears darkterbears - 1 year ago 134
iOS Question

iOS Swift EXC_BAD_ACCESS code 2 SearchTextField (UITextField subclass)

I am relatively new to iOS development with Swift (I actually have 3 years of experience with Android development with Java, trying to learn a new technology). I am creating an app that requires the usage of a library known as SearchTextField:

https://github.com/apasccon/SearchTextField

In a shellnut, it's a UITextField subclass that has a dropdown suggestions/autocomplete functionality.

Below is the ViewController that uses it...

@IBOutlet var homeAddressTextField: SearchTextField!
@IBOutlet var workAddressTextField: SearchTextField!

override func viewDidLoad() {
super.viewDidLoad()

homeAddressTextField.delegate = self
workAddressTextField.delegate = self

homeAddressTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged)
workAddressTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged)

//vvvvvvvvv EXC_BAD_ACCESS CODE 2 THROWN BELOW vvvvvvvv
homeAddressTextField.filterStrings(["foo","bar"])
}


homeAddressTextField
should be instantiated, otherwise any reference to it above should throw the same exception. When breakpointing into the problematic line, homeAddressTextField is NOT nil, and correctly shows that it is an instance of SearchTextField.

I have tried many things to fix or at least find the source of the error. As you can tell, I used a strong var instead of weak var for the Outlet.

I have tried using zombies to track any attempt to access a deallocated memory block, yet the zombie Instruments came up with no zombies accessed.

If it is worth noting, the error disappears as soon as the problematic line containing filterStrings() is removed. Any help is appreciated!

Answer Source

It seems bug in library, could you please check here

SearchTextField Issue

It is in still open issues at their repository.

Kindly watch issues in repository, if you try to use someone readymade code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download