xagaroo
4/11/2017 - 1:17 PM

Refresh tableviewcontroller

Refresh tableviewcontroller

//EJEMPLO

override func viewDidLoad() {
		super.viewDidLoad()
		
		self.refreshControl?.addTarget(self, action: #selector(ViewController.handleRefresh), for: UIControlEvents.valueChanged)
		// Do any additional setup after loading the view, typically from a nib.
}

	func handleRefresh(refreshControl: UIRefreshControl) {
		// Do some reloading of data and update the table view's data source
		// Fetch more objects from a web service, for example...
		
		// Simply adding an object to the data source for this example
		let newMovie = Movie(title: "Serenity", genre: "Sci-fi")
		movies.append(newMovie)
		
		movies.sort() { $0.title < $1.title }
		
		self.tableView.reloadData()
		refreshControl.endRefreshing()
	}