apasccon / SearchTextField

UITextField subclass with autocompletion suggestions list
MIT License
1.15k stars 254 forks source link

itemSelectionHandler using extended SearchTextFieldItem class #160

Closed DavidCollinsNZ closed 5 years ago

DavidCollinsNZ commented 5 years ago

Hi,

I've extended the SearchTextFieldItem class to mySearchTextFieldItem.

But when i use the itemSelectionHandler my added variables aren't available. Only the standard ones. Title, Subtitle, and image.

Has anyone else been able to solve this?

The filtered results are still of class SearchTextFieldItem

`class MySearchTextFieldItem: SearchTextFieldItem { public var userId: Int?

public init(title: String, subtitle: String?, userId:Int){
    super.init(title: title)
    self.title = title
    self.subtitle = subtitle
    self.userId = userId
}

} `

DavidCollinsNZ commented 5 years ago

Ah, I just figured it out! Casting

let item = filteredResults[itemPosition] as! MySearchTextFieldItem