Skip to content

Instantly share code, notes, and snippets.

@mahmudahsan
Created November 28, 2017 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmudahsan/f37106e567dc30861ef35081eff3a344 to your computer and use it in GitHub Desktop.
Save mahmudahsan/f37106e567dc30861ef35081eff3a344 to your computer and use it in GitHub Desktop.
//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