How to create a segue to another view controller through search bar? String value of result Search Bar segue to new String variable in newViewController programmatically. How I can do it?
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
// Here I'm trying catch user input
userInput = "http://api.giphy.com/v1/gifs/search?" + "q=" + searchBar.text! + "&api_key=dc6zaTOxFJmzC"
performSegue(withIdentifier: "searchView", sender: self)
}
//My segue
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue .identifier == "searchView" {
let DestViewController = segue.destination as! SearchResultController
DestViewController.userInputRequest = userInput
}
//My new View Controller
class SearchResultController: UICollectionViewController, UICollectionViewDelegateFlowLayout, UISearchBarDelegate {
var userInputRequest: String = ""
let userRequestArray = [Image]()
override func viewDidLoad() {
}