Created
November 28, 2017 03:07
-
-
Save mahmudahsan/f37106e567dc30861ef35081eff3a344 to your computer and use it in GitHub Desktop.
This file contains 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
//Single BlockOperation | |
var result:Int? | |
let multiplication = BlockOperation{ | |
result = 5 * 10 | |
} | |
multiplication.start() | |
result | |
[/code] | |
Multiple operations using BlockOperation: | |
[code lang="swift"] | |
let pairOfNumbers = [(2, 3), (5, 10), (4, 5)] | |
let blockOperations = BlockOperation() | |
for pair in pairOfNumbers{ | |
blockOperations.addExecutionBlock { | |
let result = pair.0 * pair.1 | |
print(result) | |
} | |
} | |
blockOperations.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment