AsynchronousOperation

open class AsynchronousOperation : Operation

This class is to facilitate executing asychronous requests. The caller can transition the operation to its finished state by calling finish() in the callback of an asychronous request to ensure that the operation is only removed from the OperationQueue after it has completed all its work. This class is not inherently thread safe. Although it is a subclass of Foundation’s Operation, it contains private state to support pausing, resuming, and finishing, that must be managed by callers.

Various Operation properties

  • true if the operation is ready to be executed

    Declaration

    Swift

    open override var isReady: Bool { get }
  • true if the operation is currently executing

    Declaration

    Swift

    public final override var isExecuting: Bool { get }
  • true if the operation has completed executing, either successfully or with an error

    Declaration

    Swift

    public final override var isFinished: Bool { get }
  • KVN for dependent properties

    Declaration

    Swift

    open override class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String>
  • Starts the operation

    Declaration

    Swift

    public final override func start()
  • Subclasses must implement this to perform their work and they must not call super. The default implementation of this function throws an exception.

    Declaration

    Swift

    open override func main()
  • Call this function to pause an operation that is currently executing

    Declaration

    Swift

    open func pause()
  • Call this function to resume an operation that is currently ready

    Declaration

    Swift

    open func resume()
  • Call this function to finish an operation that is currently executing

    Declaration

    Swift

    public final func finish()