Created
October 22, 2017 03:03
-
-
Save azamsharp/085f35bc9cfc9ac9bb503bf9fae40519 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment