Refresh TWTRSearchTimeline with new data

ios
fabric
swift
search

#1

I have a TWTRSearchTimelineViewController in my app that will run a search on the contents of a UITextField. This works the first time round but the I enter a new term it just shows the same data as before. Do you know where I could be going wrong?

Thanks

Here is my code:

 func textFieldShouldReturn(textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        searchTerm = searchField.text!
        
        let stl = SearchTimelineViewController()
        stl.dataSource = TWTRUserTimelineDataSource(screenName: "\(searchTerm)", APIClient: stl.client)
        stl.refresh()
        stl.tableView.reloadData()
     
        return true
    }

#2

Did you mean to do a user or search timeline? It seems like you have a bug in setting the data source for your timeline to be username = the search term and there’s probably no username that matches the search term:

stl.dataSource = TWTRUserTimelineDataSource(screenName: "\(searchTerm)", APIClient: stl.client)

#3

Sorry. That line should be:
stl.dataSource = TWTRSearchTimelineDataSource(searchQuery: "\(searchTerm)", APIClient: stl.client)

I pasted the code before I made that change. It still doesn’t seem to be working.

Any ideas?