Created
November 27, 2013 16:02
-
-
Save isutton/7678143 to your computer and use it in GitHub Desktop.
NSOperation dependency creep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableDictionary *context = [NSMutableDictionary dictionary]; | |
// Adds information in context under the key "fromOp1" | |
Op1 *op1 = [[Op1 alloc] initWithContext:context]; | |
// Consumes "fromOp1" from context and add info under the key "fromOp2" | |
Op2 *op2 = [[Op2 alloc] initWithContext:context]; | |
[op2 addDependency:op1]; | |
// Adds info in context under the key "fromOp3" | |
Op3 *op3 = [[Op3 alloc] initWithContext:context]; | |
// Consumes "fromOp3" from context and add info under the key "fromOp4" | |
Op4 *op4 = [[Op4 alloc] initWithContext:context]; | |
[op4 addDependency:op3]; | |
// Add info under the key "fromOp5" | |
Op5 *op5 = [[Op5 alloc] initWithContext:context]; | |
[op5 addDependencies:@[op2, op4]]; | |
// Consumes "fromOp2", "fromOp4" and "fromOp5" from context. | |
Op6 *op6 = [[Op6 alloc] initWithContext:context]; | |
[op6 addDependency:op5]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The reason "context" is being sent to all the operations is that the results are needed in each step of the dependency chain.