GCD Threads

Grand Central Dispatch makes asynchronous programming easier and safer by hiding threads from developer.

Types of Queues
sync, async

Main Queue

dispatch_get_global_queue()
dispatch_async()

let q = dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0)

dispatch_async(q) { () -> Void in
	print("tic")
}
print("tac")

will it crash?

let downloadQueue = dispatch_queue_create("download", nil)

dispatch_async(downloadQueue)() -> Void in
	let imgData = NSData(contentsOfURL:url!)

	let image = UIImage(data:imgData!)

	self.photoView.image = image
@IBAction func synchronousDownload(_ sender: UIBarButtonItem){
	let url = URL(string: BigImages.seaLion.rawValue)
	let imgData = try? Data(contentsOf: url!)
	let image = UIImage(data: imgData!)

	photoView.image = image
}