forked from codecat15/Youtube-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContents.swift
48 lines (33 loc) · 1.25 KB
/
Contents.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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()