Created
June 10, 2020 10:37
-
-
Save stevencurtis/5f5f07f25a0b4d62096bd9f927007fc8 to your computer and use it in GitHub Desktop.
OperationHelloWorld
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
class PrintOperation: Operation { | |
let stringToPrint: String | |
init(stringToPrint: String = "I don't have manners") { | |
self.stringToPrint = stringToPrint | |
super.init() | |
} | |
override func main() { | |
guard !isCancelled else { return } | |
print(stringToPrint) | |
} | |
} | |
let queue = OperationQueue() | |
let printOperation = PrintOperation(stringToPrint: "Hello, World!") | |
printOperation.completionBlock = { | |
print("Done!") | |
} | |
queue.addOperation(printOperation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment