Created
November 14, 2016 10:28
-
-
Save arto-heino/7ece185c6fbfe0e9b6cd9744978cfbc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PodcastTableViewController: UITableViewController, DataParserObserver { | |
var podcasts = [Podcast]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.podcasts = [Podcast]() | |
let dataParser = HttpRequesting() | |
dataParser.httpGetPodCasts(parserObserver: self) | |
} | |
func podcastsParsed(podcasts: [Podcast]) { | |
self.podcasts = podcasts | |
DispatchQueue.main.async { | |
self.tableView.reloadData() | |
return | |
} | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
// MARK: - Table view data source | |
override func numberOfSections(in tableView: UITableView) -> Int { | |
return 1 | |
} | |
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return self.podcasts.count | |
} | |
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cellIdentifier = "PodcastCell" | |
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! PodcastTableViewCell | |
cell.collectionLabel.text = self.podcasts[indexPath.row].collection | |
cell.descriptionLabel.text = self.podcasts[indexPath.row].description | |
cell.durationLabel.text = self.podcasts[indexPath.row].duration | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment