iOS Concurrency with GCD & Operations

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

Part 3: Operations & OperationQueues

21. Challenge: Implement a Dependency

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 20. Dependencies Next episode: 22. Cancel Operations

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’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Challenge: Implement Dependency

Continue with your final project from the previous video or open the starter project. Update downloadImageOp in ImageStore to apply the tilt-shift filter to the downloaded image.

let downloadOp = NetworkImageOperation(url: images[index].url)
let tiltShiftOp = TiltShiftOperation()
tiltShiftOp.addDependency(downloadOp)
tiltShiftOp.completionBlock = {  // change operation to tiltShiftOp
  guard let image = tiltShiftOp.image else { return }  // change operation to tiltShiftOp
  DispatchQueue.main.async {
    self.images[index].image = image
  }
}
queue.addOperation(downloadOp)
queue.addOperation(tiltShiftOp)