I integrate autocomplete event in my app. when I configure textfield
I got this error
Cannot subscript a value of type '[String : AnyObject]' with an index of type 'NSAttributedStringKey'
Please check below code:
fileprivate func configureTextField(){
print("i am here 4")
autocompleteTextfield.autoCompleteTextColor = UIColor(red: 128.0/255.0, green: 128.0/255.0, blue: 128.0/255.0, alpha: 1.0)
autocompleteTextfield.autoCompleteTextFont = UIFont(name: "HelveticaNeue-Light", size: 12.0)!
autocompleteTextfield.autoCompleteCellHeight = 35.0
autocompleteTextfield.maximumAutoCompleteCount = 20
autocompleteTextfield.hidesWhenSelected = true
autocompleteTextfield.hidesWhenEmpty = true
autocompleteTextfield.enableAttributedText = true
***var attributes = [String:AnyObject]()
attributes[NSForegroundColorAttributeName] = UIColor.black
attributes[NSFontAttributeName] = UIFont(name: "HelveticaNeue-Bold", size: 12.0)
autocompleteTextfield.autoCompleteAttributes = attributes***
}
I got error on NSForegroundColorAttributeName,NSFontAttributeName and attributes
and for autocomplete I import autocomplete UITextfield
file. I got above error in below method:
> open var autoCompleteAttributes:[String:AnyObject]?
fileprivate func commonInit(){
hidesWhenEmpty = true
autoCompleteAttributes = [NSForegroundColorAttributeName.rawValue:UIColor.black]
autoCompleteAttributes![NSFontAttributeName] = UIFont.boldSystemFont(ofSize: 12)
self.clearButtonMode = .always
self.addTarget(self, action: #selector(AutoCompleteTextField.textFieldDidChange), for: .editingChanged)
self.addTarget(self, action: #selector(AutoCompleteTextField.textFieldDidEndEditing), for: .editingDidEnd)
}
I got error autoCompleteAttributes![NSFontAttributeName] this line. I do not what happen please check code...