ArcGIS Runtime SDK for iOS: AGSObservableOperation Class Reference
ArcGIS Runtime SDK for iOS  100.12
AGSObservableOperation Class Reference

Description

Base class for operations. This adds the ability to register a listener to the AGSOperationBase. It also adds the concept of an error and a result.

Since
100
Inheritance diagram for AGSObservableOperation:
AGSOperationBase <AGSOperation> AGSRequestOperation AGSJSONRequestOperation

Instance Methods

(void) - cancel
 
(void) - didComplete:
 
(void) - doCancel
 
(void) - doExecute
 
(void) - doneExecuting
 
(void) - execute
 
(BOOL) - isRegisteredListener:
 
(void) - registerListener:forCompletion:
 
(void) - unregisterListener:
 

Properties

BOOL canceled
 
NSError * error
 
void(^ internalCompletion )(void)
 
id result
 
BOOL startAsynchronously
 
AGSOperationState state
 

Method Documentation

◆ cancel

- (void) cancel

Cancels the operation.

Since
100

◆ didComplete:

- (void) didComplete: (BOOL)  everStarted

Subclasses should override if they want to run some code once the operation is completed. This function is guaranteed to only be called once. everStarted will be NO if the operation was canceled before it could be started.

Since
100

Provided by category AGSOperationBase(ForSubclassEyesOnly).

◆ doCancel

- (void) doCancel

Subclasses can override to do the actual work to cancel the operation. Once cancel is complete, call doneExecuting. For operations that do not do all of their work in doExecute, it makes sense to override this and cancel any network connections, etc. Then when the cancel is complete, you call doneExecuting. For operations where the work is all done in doExecute they shouldn't need to override this, you should just check the isCanceled property throughout the execution of the operation and if it is canceled then call doneExecuting and return.

Since
100

Provided by category AGSOperationBase(ForSubclassEyesOnly).

◆ doExecute

- (void) doExecute

Subclasses should override to do the actual execution of the operation. Once done, call doneExecuting.

Since
100

Provided by category AGSOperationBase(ForSubclassEyesOnly).

◆ doneExecuting

- (void) doneExecuting

Subclasses should call this when they are done executing or done cancelling.

Since
100

Provided by category AGSOperationBase(ForSubclassEyesOnly).

◆ execute

- (void) execute

Starts the operation

Since
100

◆ isRegisteredListener:

- (BOOL) isRegisteredListener: (id)  listener

Returns whether or not the specified object is a registered as a listener to this operation.

Since
100

◆ registerListener:forCompletion:

- (void) registerListener: (id)  listener
forCompletion: (void(^)(id __nullable result, NSError *__nullable error))  completion 

Adds a completion handler to the operation for the specified listener. If you are using this option, you can unregister a completionHandler for a listener if you need to. When there are no more listeners the operation will be canceled automatically.

Parameters
listenerThe listener to add the completion block for.
completionThe completion handler to be called.
Since
100

◆ unregisterListener:

- (void) unregisterListener: (id)  listener

Removes the registered completion handler to the operation for the specified listener. When there are no more listeners the operation will be canceled automatically. To avoid any potential retain cycles the listener is not retained by the operation. Unregistering is just the way to tell the operation that you no longer care about getting the completion event.

Parameters
listenerThe listener to unregister
Since
100

Property Documentation

◆ canceled

- (BOOL) canceled
readnonatomicassigninherited

Whether or not cancel has been called on the operation. "Canceled" is a modifier on the current state since:

  1. The operation can be still "executing" until the cancel takes effect.
  2. An operation can be canceled and in a completed state at the same time.
    Since
    100

◆ error

- (NSError*) error
readnonatomicstrong

The error, if any, that occurred.

Since
100

◆ internalCompletion

- (void(^ internalCompletion) (void))
readwritenonatomiccopyinherited

The block the operation will call to signify to the operation queue that the operation is complete. This block is reserved for use by the AGSOperationQueue. Do not assign your own block to this.

Since
100

◆ result

- (id) result
readnonatomicstrong

The results of an operation. It will be of type NSDictionary when the result is json, AGSImage when the result is an image, and NSData when anything else.

Since
100

◆ startAsynchronously

- (BOOL) startAsynchronously
readwritenonatomicassigninherited

Subclasses can set this if they want to be started asynchronously or not. If an operation does most or all of it's work in doExecute it should set this to YES. If an operation returns quickly from doExecute and does all of it's work on a different queue then this value should be NO. The default value is YES.

Provided by category AGSOperationBase(ForSubclassEyesOnly).

◆ state

- (AGSOperationState) state
readnonatomicassigninherited

The current state of the operation.

Since
100