EddyBorja / MLPAutoCompleteTextField

UITextfield subclass with autocomplete menu. For iOS.
Other
1.21k stars 222 forks source link

Swift 3 Thread Issue! #108

Closed dcflow closed 8 years ago

dcflow commented 8 years ago

Hi,

On Swift 3 this gives a thread error. On Swift 2 it used to work fine.

private func autoCompleteTextField(_ textField: MLPAutoCompleteTextField!, possibleCompletionsFor string: String!, completionHandler handler: (([AnyObject]?) -> Void)!) {

        DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async {
            let completions: [String] = ["a", "b", "c"]

            handler(completions as [AnyObject])
        }
    }

Thank You!

NOlivNeto commented 7 years ago

You managed to get it working?

dcflow commented 7 years ago

As I recall I just removed the async queue.

private func autoCompleteTextField(_ textField: MLPAutoCompleteTextField!, possibleCompletionsFor string: String!, completionHandler handler: (([AnyObject]?) -> Void)!) {
        let completions: [String] = ["a", "b", "c"]

        handler(completions as [AnyObject])
    }

There is also another autocomplete func that you should try.