5

Is it possible to pass data from an NSOperation up the dependency chain to be used by the next NSOperation?

Thanks

Chris

Chris
  • 2,739
  • 4
  • 29
  • 57

2 Answers2

5

Yes. The current NSOperation can access it's dependancies via the dependencies method:

NSArray *myDependancies = [self dependencies];

It can then access whatever properties you wish on the previous operations and pull out any data it requires.

In a recent project I found that I needed to pass data along so often that I created a subclass of NSOperation that automatically carried forward an NSDictionary of data from one operation to the next.

Rory O'Bryan
  • 1,894
  • 14
  • 22
0

I've read the post where you can pass data between operations.

Also raywenderlich book Concurrency by Tutorials shows that you can pass data from dependecies like this:

let dependencyImage = dependencies
.compactMap { ($0 as? ImageDataProvider)?.image } .first
Grigory
  • 53
  • 6