Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private func loadArticles() {
- // this url should be part of the URL builder scheme and not right inside the
- // view controller but right now we are focused on MVVM
- let url = URL(string: "https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest&apiKey=0cf790498275413a9247f8b94b3843fd")!
- // this web service should use generic types. Again this is not part of the implementation
- // as we are focusing on MVVM model
- Webservice().getArticles(url: url) { articles in
- print(articles)
- let articles = articles.map { article in
- return ArticleViewModel(article :article)
- }
- self.viewModel = ArticleListViewModel(articles :articles)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement