Created
January 16, 2020 17:29
-
-
Save nalexn/f3f00e93eda6b81e1b717a7f15d52c1d to your computer and use it in GitHub Desktop.
Article_008 https://nalexn.github.io/separation-of-concerns/
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 ListViewController: UIViewController { | |
var items: [Item] = [] | |
var tableView: UITableView? | |
override func viewDidLoad() { | |
let url = URL(string: "https://api.service.com/list")! | |
let request = URLRequest(url: url) | |
URLSession.shared.dataTask(with: request) { [weak self] (data, response, error) in | |
if let list = try? JSONDecoder().decode([Item].self, from: data ?? Data()) { | |
self?.items = list | |
self?.tableView?.reloadData() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment