Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Webservice loadSources Function
func loadSources(completion :@escaping ([Source]) -> ()) {
URLSession.shared.dataTask(with: sourcesURL) { data, _, _ in
if let data = data {
let json = try! JSONSerialization.jsonObject(with: data, options: [])
let sourceDictionary = json as! JSONDictionary
let dictionaries = sourceDictionary["sources"] as! [JSONDictionary]
let sources = dictionaries.flatMap(Source.init)
DispatchQueue.main.async {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment