EddyBorja / MLPAutoCompleteTextField

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

swift2.x -> swift3.x autocomplete suggestions crashes in Swift3.x #115

Open Nihonda opened 7 years ago

Nihonda commented 7 years ago

Dear Eddy Borja

Asynchronous managing of a drop down table of autocomplete suggestions crashes in Swift3.x

NSAssert(0, @"An autocomplete datasource must implement either autoCompleteTextField:possibleCompletionsForString: or autoCompleteTextField:possibleCompletionsForString:completionHandler:"); But same works perfectly in Swift 2.x. Probably Apple change logics again. Please check.

It has been more than 2 years after update of your github repository.

Could you please address this issue.

Waiting so much, thank you

FCZLumpy commented 7 years ago

func autoCompleteTextField(_ textField: MLPAutoCompleteTextField!, possibleCompletionsForString: String!, completionHandler handler: (([AnyObject]?) -> Void)!) it works for me

ericwastaken commented 6 years ago

It appears that the Swift converter changes the signature in a way that causes the crash.

In my case, I was able to replace it with the below, which resolved the crash. Note, I'm already up to Swift 4.1 so this syntax might not be 3.x compatible (didn't check).

internal func autoCompleteTextField(_ textField: MLPAutoCompleteTextField!, possibleCompletionsFor string: String!) -> [Any]! {

    var result = [] as Array

    // YOUR LOGIC HERE TO POPULATE result

    // Return our result
    return result as [Any]

  }