Reachable Operation

ReachableCondition will ensure that a provided host is reachable before executing an operation. This is great, but in some cases there is not a known host, for example, when using CloudKitOperation where the device must be online. In these situations, we can compose an operation inside a ReachableOperation.

let operation = ReachableOperation(aCriticalNetworkingOperation)
queue.addOperation(operation)

The ReachableOperation will register itself with an internal Reachability service, so that only when the status is available will the composed operation be executed.


Did this page help you?