Created
June 7, 2018 22:50
-
-
Save deda9/c7da68195ba82ce3f7880deca3101609 to your computer and use it in GitHub Desktop.
How to create Dependencies for NSOperationBlock in swift
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
let operationQueue = OperationQueue() | |
let op0 = BlockOperation() | |
op0.completionBlock = { | |
print("op0 completionBlock") | |
} | |
op0.addExecutionBlock { | |
print("op0 executionBlock #1") | |
} | |
op0.addExecutionBlock { | |
print("op0 executionBlock #2") | |
} | |
op0.queuePriority = .veryHigh | |
let op1 = BlockOperation() | |
op1.addDependency(op0) | |
op1.completionBlock = { | |
print("op1 completionBlock") | |
} | |
op1.addExecutionBlock { | |
print("op1 executionBlock") | |
} | |
let op2 = BlockOperation() | |
op2.addDependency(op1) | |
op2.completionBlock = { | |
print("op2 completionBlock") | |
} | |
op2.addExecutionBlock { | |
print("op2 executionBlock") | |
} | |
operationQueue.addOperations([op0, op1, op2], waitUntilFinished: true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment