I have a vc with one segmentedControl, I want to be able to change the function called by the refresher everytime the segmentedControl's index is changed
lazy var refresher: UIRefreshControl = {
let refreshControl = UIRefreshControl()
if (segmentedControl.selectedSegmentIndex == 0){
refreshControl.addTarget(self, action: #selector(loadRecommend1), for: .valueChanged)
} else if (segmentedControl.selectedSegmentIndex == 1){
refreshControl.addTarget(self, action: #selector(loadCompletePosts1), for: .valueChanged)
} else if (segmentedControl.selectedSegmentIndex == 2){
refreshControl.addTarget(self, action: #selector(loadCompletePostsByHealthy1), for: .valueChanged)
}
return refreshControl
}()
Currently the first function is called everytime despite the selected item in the segmentedControl