Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created October 22, 2017 03:03
Show Gist options
  • Save azamsharp/085f35bc9cfc9ac9bb503bf9fae40519 to your computer and use it in GitHub Desktop.
Save azamsharp/085f35bc9cfc9ac9bb503bf9fae40519 to your computer and use it in GitHub Desktop.
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