Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass data from NSOperation to next NSOperation

Tags:

nsoperation

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

Thanks

Chris

like image 914
Chris Avatar asked Jul 01 '13 10:07

Chris


1 Answers

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.

like image 73
Rory O'Bryan Avatar answered Oct 29 '22 17:10

Rory O'Bryan