ONGNetworkTask Class Reference

Inherits from NSObject
Declared in ONGNetworkTask.h

Overview

ONGNetworkTask is a cancelable object, representing the actual network request. It offers cancelling, pausing and resuming requests. Produced by [ONGUserClient fetchResource:completion:], [ONGDeviceClient fetchResource:completion:] and [ONGDeviceClient fetchUnauthenticatedResource:completion:].

  identifier

Unique identifier given to every task.

@property (copy, readonly) NSString *identifier

Declared In

ONGNetworkTask.h

  state

Value representing the actual state of the task. the initial state is: ONGNetworkTaskStateRunning. You may want to observer it through KVO.

@property (readonly) ONGNetworkTaskState state

Declared In

ONGNetworkTask.h

  request

@property (readonly) ONGResourceRequest *request

Declared In

ONGNetworkTask.h

  response

The response value fulfilled upon completion. It may be nil if the network task hasn’t received any response from the server yet.

@property (readonly, nullable) ONGResourceResponse *response

Declared In

ONGNetworkTask.h

  error

The Error value fulfilled upon completion. It may be nil in case of a successful response.

@property (readonly, nullable) NSError *error

Discussion

This error will be either within the NSURLErrorDomain or ONGGenericErrorDomain.

Declared In

ONGNetworkTask.h

– init

You should not try to instantiate a task on your own. The only valid way to get a valid task instance is by calling [ONGUserClient fetchResource:completion:], [ONGDeviceClient fetchResource:completion:] or [ONGDeviceClient fetchUnauthenticatedResource:completion:].

- (instancetype)init

Declared In

ONGNetworkTask.h

– resume

Resume a suspended task. This moves a task from the ONGNetworkTaskStateSuspended state to the ONGNetworkTaskStateRunning state. If a task is already completed (ONGNetworkTaskStateCompleted) or cancelled (ONGNetworkTaskStateCancelled) - this won’t have any effect.

- (void)resume

Discussion

By default you don’t have to call resume - the SDK starts a task automatically.

Any attempt to resume an already running task doesn’t have any effect.

Declared In

ONGNetworkTask.h

– suspend

Suspend running task. This moves a task from the ONGNetworkTaskStateRunning state to the ONGNetworkTaskStateSuspended state.

- (void)suspend

Discussion

Any attempt to suspend an already suspended, cancelled (ONGNetworkTaskStateCancelled) or completed (ONGNetworkTaskStateCompleted) task doesn’t have any effect.

Declared In

ONGNetworkTask.h

– cancel

Cancel a running or suspended task. This moves the task to the ONGNetworkTaskStateCancelled state.

- (void)cancel

Discussion

Any attempt to cancel an already cancelled or completed (ONGNetworkTaskStateCompleted) task doesn’t have any effect.

Declared In

ONGNetworkTask.h