Created
November 12, 2019 23:06
-
-
Save shanecowherd/d279c623d922429d1c7ef7c892f56a33 to your computer and use it in GitHub Desktop.
Example Operation
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
let operationQueue = OperationQueue() | |
class ExampleOperation: Operation { | |
var delegate: SomeDelegate | |
var callbackDelegate: SomeCallbackDelegate | |
var success = false // I mark this when the operation has succeeded. Optional | |
init(delegate: SomeDelegate, callbackDelegate: SomeCallbackDelegate) { | |
self.delegate = delegate | |
self.callbackDelegate = callbackDelegate | |
} | |
override func main() { | |
let waitForFinish = DispatchGroup() | |
waitForFinish.enter() | |
// Do stuff here and leave when you are done | |
waitForFinish.leave() | |
waitForFinish.wait() | |
if self.isCancelled { return } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment