0

I followed the instructions in Customizing QuickType Suggestions in iOS. I get a crash with error

setAutocompleteWithDataSource:delegate:customize:]: unrecognized selector sent to instance 0x7fe8c981bc00'

The relevant code is simply:

@IBOutlet weak var brand: UITextField! 

override func viewDidLoad() { 
    super.viewDidLoad() 
    . . .
    self.brand.setAutocompleteWith(self, delegate: self, customize: { inputView in
            inputView?.isHidden = false
        })
}

I'm using Xcode 9.1, and swift 3. I don't grok the syntax for closures when used with objective C. Can you see my error?

Note that I added the context of the call to setAutocompleteWith. Is viewDidLoad() a good place do do the call?

John B
  • 11
  • 4

1 Answers1

0

It looks like you didn't type the function name properly.

Try this instead:

@IBOutlet weak var brand: UITextField! 

self.brand.setAutocompleteWithDataSource(self, delegate: self, customize: { inputView in
            inputView?.isHidden = false
        })
tww0003
  • 801
  • 9
  • 18
  • Thanks. But when I try that, Xcode tells me: `setAutocompleteWithDataSource(_:delegate:customize:)' has been renamed to 'setAutocompleteWith(_:delegate:customize:)'` – John B Dec 08 '17 at 17:28