Skip to content

Instantly share code, notes, and snippets.

@aybekckaya
Created May 15, 2019 23:01
Show Gist options
  • Select an option

  • Save aybekckaya/d7e52cc0e6dd2d13b24eca2205d198cf to your computer and use it in GitHub Desktop.

Select an option

Save aybekckaya/d7e52cc0e6dd2d13b24eca2205d198cf to your computer and use it in GitHub Desktop.
guard let jsonDct:[String:Any] = readJsonFile() , let arrCategoriesDct:[[String:Any]] = jsonDct["categories"] as? [[String:Any]] else { return }
let categories:[Category] = arrCategoriesDct.compactMap { dct -> Category? in
return Category(dct: dct)
}
var completedCount:Int = 0
categories.forEach { category in
self.asyncTask(imageURL: category.thumbnailImage, completion: { image in
completedCount += 1
if completedCount == categories.count {
print("Finished All Tasks")
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment