Skip to content

Commit

Permalink
operation queue basic demo
Browse files Browse the repository at this point in the history
  • Loading branch information
codecat15 committed Feb 28, 2021
1 parent 08f0e26 commit 4a8c42e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import UIKit

/*
this was just a small demo of operation and operation queue in the coming days we will see few more examples with operation queue to explore them in details. If the video was helpful then please do like and share with your iOS group and please do support the channel by subscribing to it and sharing it with your iOS group

Thank you
~ CodeCat15

*/


struct Example
{
func doWork() {

let blockOperation = BlockOperation()

blockOperation.addExecutionBlock {
debugPrint("Hello")
}

blockOperation.addExecutionBlock {
debugPrint("my name is")
}

blockOperation.addExecutionBlock {
debugPrint("Ravi")
}

// blockOperation.start()

let anotherBlockOperation = BlockOperation()
anotherBlockOperation.addExecutionBlock {
debugPrint("I am another block operation")
}

let operationQueue = OperationQueue()
operationQueue.qualityOfService = .utility
//operationQueue.addOperation(blockOperation)
// operationQueue.addOperation(anotherBlockOperation)

operationQueue.addOperations([blockOperation, anotherBlockOperation], waitUntilFinished: false)

}
}

let obj = Example()
obj.doWork()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' buildActiveScheme='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

0 comments on commit 4a8c42e

Please sign in to comment.