iOS Concurrency with GCD & Operations

Sep 12 2023 · Swift 5.8, macOS 13, iOS 16, Xcode 14.3

Part 3: Operations & OperationQueues

20. Dependencies

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 19. Challenge: Download Images in OperationQueue Next episode: 21. Challenge: Implement a Dependency

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

In Part 1, you set up a simple dependency to update the UI after a background task finishes, using the notify method of DispatchWorkItem.

  execute: updateUIWorkItem)
userQueue.async(execute: backgroundWorkItem)
let downloadOp = NetworkImageOperation(url: urls[indexPath.row])
let tiltShiftOp = TiltShiftOperation()
import UIKit

protocol ImageDataProvider {
  var image: UIImage? { get }
extension NetworkImageOperation: ImageDataProvider {}
extension TiltShiftOperation: ImageDataProvider {
  var image: UIImage? { return outputImage }
let dependencyImage = dependencies
  .compactMap { ($0 as? ImageDataProvider)?.image }
guard let inputImage = inputImage ?? dependencyImage 
else { return }
init(image: UIImage? = nil) {