mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-06-07 13:05:17 +00:00
COVIDSafe code from version 1.1
This commit is contained in:
commit
3640e52eb2
330 changed files with 261540 additions and 0 deletions
72
CovidSafe/Feedback/Sources/AsyncAction.swift
Executable file
72
CovidSafe/Feedback/Sources/AsyncAction.swift
Executable file
|
@ -0,0 +1,72 @@
|
|||
// Copyright © 2015 Australian Government All rights reserved.
|
||||
|
||||
import Foundation
|
||||
|
||||
open class AsyncAction: Operation {
|
||||
|
||||
fileprivate var _executing = false
|
||||
fileprivate var _finished = false
|
||||
|
||||
override fileprivate(set) open var isExecuting: Bool {
|
||||
get {
|
||||
return _executing
|
||||
}
|
||||
set {
|
||||
willChangeValue(forKey: "isExecuting")
|
||||
_executing = newValue
|
||||
didChangeValue(forKey: "isExecuting")
|
||||
}
|
||||
}
|
||||
|
||||
override fileprivate(set) open var isFinished: Bool {
|
||||
get {
|
||||
return _finished
|
||||
}
|
||||
set {
|
||||
willChangeValue(forKey: "isFinished")
|
||||
_finished = newValue
|
||||
didChangeValue(forKey: "isFinished")
|
||||
}
|
||||
}
|
||||
|
||||
override open var completionBlock: (() -> Void)? {
|
||||
set {
|
||||
super.completionBlock = newValue
|
||||
}
|
||||
get {
|
||||
return {
|
||||
super.completionBlock?()
|
||||
self.actionCompleted()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override open var isAsynchronous: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
override open func start() {
|
||||
if isCancelled {
|
||||
isFinished = true
|
||||
return
|
||||
}
|
||||
|
||||
isExecuting = true
|
||||
autoreleasepool {
|
||||
self.run()
|
||||
}
|
||||
}
|
||||
|
||||
func run() {
|
||||
preconditionFailure("This abstract method must be overridden.")
|
||||
}
|
||||
|
||||
func actionCompleted() {
|
||||
//optional
|
||||
}
|
||||
|
||||
func finishedExecutingOperation() {
|
||||
isExecuting = false
|
||||
isFinished = true
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue