The solution shows how the code is fixed and how to put code in the background thread to free up the main thread.
(upbeat music) … - [Instructor] You need to solve two issues in this app. … Number one is ensuring … that our UI is updated from the main thread … and number two, that you are caching our images. … So we're going to start with the first issue. … Head on to PhotoCell … and then to your SetPhotoCellWidth function. … The code called here is for updating the UI. … So you are going to ensure … that it's called for the main thread … with DispatchQueue.main.async … and then you transfer this code to our braces. … All right, so now that solves the first issue. … Then you're going to go to the Extensions files … hereby we are loading the image … onto our image cell … and you're going to create an instance of a cache. … Let imageToCache … equals to NSCache … and it's going to take an NSString. … And the UIImage. … All right. … So now, once the function is called, … the first thing you're going to do … is set our image to nil. … We need to make sure this is self. … The next thing you're going to do, …
Skill Level Intermediate
1. Evolution of GCD
2. Working with Queues
3. Asychronous vs. Synchronous Execution
4. Concurrency vs. Parallelism
What are deadlocks?1m 21s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.