ArcGIS Runtime SDK for iOS: AGSArcadeEvaluator Class Reference
ArcGIS Runtime SDK for iOS  100.15
AGSArcadeEvaluator Class Reference

Description

This object allows you to evaluate an AGSArcadeExpression under a given AGSArcadeProfile.

This object allows you to set up, execute and query information about an Arcade script. For more general information on Arcade and its usages check out the Arcade online documentation.

To construct the AGSArcadeEvaluator object you need to supply an AGSArcadeExpression along with an AGSArcadeProfile. AGSArcadeExpression is an object that contains the Arcade script plus some additional metadata while AGSArcadeProfile specifies availability of profile variables and limits what functions are available.

The basic workflow is:

From an AGSArcadeEvaluator object you can query information to determine,

  • Which profile variables are accessed by the script.
  • Which attributes are used by a particular profile variable.
  • If the script is considered stable.

Not all scripts use all the profiles variables. The AGSArcadeEvaluator::profileVariablesUsed returns an array of the names of the profile variables used in the current script. Possible uses include:

  • Informing dependency analysis to determine which scripts need to run when a value of a profile variable changes.
  • Minimizing expensive calculation of unneeded profile variables.

The attributesWithVariableName:featureTableSource:completion: (AGSArcadeEvaluator) and attributesWithVariableName:geoElementSource:completion: (AGSArcadeEvaluator) lets you dig deeper to determine which attributes are required on a specific profile variable. If you are querying a subset of attributes when querying a feature, use this information to ensure the profile variable will have the attributes it requires.

The AGSArcadeEvaluator::stable property indicates if the given script will return the same value for an identical set of profile variables. For this to be true a script must avoid using unstable builtin functions such as 'now()' or 'random()'.

The AGSArcadeEvaluator::stable can be combined with the knowledge of the used profile variables to construct caches of results. This lets you avoid running scripts when repeated calls with the same profiles variables will not alter the evaluation result.

Since
100.14
Inheritance diagram for AGSArcadeEvaluator:
AGSLoadableBase AGSObject <AGSLoadable>

Instance Methods

(id< AGSCancelable >) - attributesWithVariableName:featureTableSource:completion:
 
(id< AGSCancelable >) - attributesWithVariableName:geoElementSource:completion:
 
(void) - cancelLoad
 
(void) - doCancelLoading
 
(void) - doStartLoading:
 
(id< AGSCancelable >) - evaluateWithProfileVariables:completion:
 
(instancetype) - initWithExpression:profile:
 
(void) - loadDidFinishWithError:
 
(void) - loadWithCompletion:
 
(void) - onLoadStatusChanged
 
(void) - retryLoadWithCompletion:
 

Class Methods

(instancetype) + arcadeEvaluatorWithExpression:profile:
 

Properties

AGSArcadeExpressionexpression
 
NSError * loadError
 
AGSLoadStatus loadStatus
 
AGSArcadeProfile profile
 
NSArray< NSString * > * profileVariablesUsed
 
BOOL stable
 

Method Documentation

◆ arcadeEvaluatorWithExpression:profile:

+ (instancetype) arcadeEvaluatorWithExpression: (AGSArcadeExpression *)  expression
profile: (AGSArcadeProfile profile 

Creates an AGSArcadeEvaluator object.

Parameters
expressionThe Arcade expression to be evaluated.
profileThe Arcade profile under which the expression will be evaluated.
Since
100.14

◆ attributesWithVariableName:featureTableSource:completion:

- (id<AGSCancelable>) attributesWithVariableName: (NSString *)  variableName
featureTableSource: (AGSFeatureTable *)  featureTableSource
completion: (void(^)(NSArray< NSString * > *__nullable result, NSError *__nullable error))  completion 

An array of attributes used in the script for a given profile variable.

To fully support the wildcard expansion in the expects statement, calculation of used attributes on a profile variable requires an object that can supply a full set of attribute names.

Parameters
variableNameThe name of the profile variable whose used attributes are required.
featureTableSourceA AGSFeatureTable from which we can obtain a list of all attributes names for the profile variable.
completionBlock that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated.
Returns
An operation which can be canceled.
Since
100.14

◆ attributesWithVariableName:geoElementSource:completion:

- (id<AGSCancelable>) attributesWithVariableName: (NSString *)  variableName
geoElementSource: (id< AGSGeoElement >)  geoElementSource
completion: (void(^)(NSArray< NSString * > *__nullable result, NSError *__nullable error))  completion 

An array of attributes used in the script for a given profile variable.

To fully support the wildcard expansion in the expects statement, calculation of used attributes on a profile variable requires an object that can supply a full set of attribute names.

Parameters
variableNameThe name of the profile variable whose used attributes are required.
geoElementSourceA AGSGeoElement from which we can obtain a list of all attributes names for the profile variable.
completionBlock that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated.
Returns
An operation which can be canceled.
Since
100.14

◆ cancelLoad

- (void) cancelLoad
requiredinherited

Cancels loading if it is in progress, otherwise it does nothing. This should be called carefully because other objects could be waiting for loadWithCompletion: or retryLoadWithCompletion: to complete and this will call them all back with the error of NSUserCancelledError

Since
100

◆ doCancelLoading

- (void) doCancelLoading

Never call this method directly. The framework calls this method on a background thread when cancelLoad (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to cancel loading their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) at the end passing in an error representing NSUserCancelledError.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ doStartLoading:

- (void) doStartLoading: (BOOL)  retrying

Never call this method directly. The framework calls this method on a background thread when loadWithCompletion: (AGSLoadable-p) or retryLoadWithCompletion: (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to load their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) upon completion, passing in the error if any.

Parameters
retryingflag that is true if this method was called from retryLoadWithCompletion: (AGSLoadable-p).
Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ evaluateWithProfileVariables:completion:

- (id<AGSCancelable>) evaluateWithProfileVariables: (NSDictionary< NSString *, id > *)  profileVariables
completion: (void(^)(AGSArcadeEvaluationResult *__nullable result, NSError *__nullable error))  completion 

Evaluate the script using the supplied profile variables.

Each entry of the profileVariables dictionary is placed into the interpreter as a value accessible throughout the script. The name and type of these should comply with the profile the Arcade evaluator has been constructed with. Values are not persisted across evaluations, meaning all required profile variables must be supplied with each evaluation.

Each value of a key/value pair in the dictionary is converted to a type understood by the interpreter.

Values in the dictionary can be any of the following runtime types:

To be explicit on the conversions of compound types:

  • AGSGeoElement types are converted to Arcade Feature type.
  • AGSLocation is converted to an Arcade Feature type.
  • AGSFeatureTable types are converted to Arcade FeatureSet type.
  • AGSGeodatabase is converted to Arcade FeatureSetCollection type.
  • AGSServiceGeodatabase is converted to Arcade FeatureSetCollection type.
  • AGSGeoModel is converted to Arcade FeatureSetCollection type.
    Parameters
    profileVariablesThe profile variables for the script as key/value pairs.
    completionBlock that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated.
    Returns
    An operation which can be canceled.
    Since
    100.14

◆ initWithExpression:profile:

- (instancetype) initWithExpression: (AGSArcadeExpression *)  expression
profile: (AGSArcadeProfile profile 

Creates an AGSArcadeEvaluator object.

Parameters
expressionThe Arcade expression to be evaluated.
profileThe Arcade profile under which the expression will be evaluated.
Since
100.14

◆ loadDidFinishWithError:

- (void) loadDidFinishWithError: (nullable NSError *)  error

Only subclasses should call this method in doStartLoading: (AGSLoadableBase(ForSubclassEyesOnly)) and doCancelLoading (AGSLoadableBase(ForSubclassEyesOnly)) when done loading or failed to load.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ loadWithCompletion:

- (void) loadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Loads data for the object asynchronously. The completion block is invoked upon completion.

You can call this method any number of times, however only one attempt is made to load the data. If it is already loading, it will just continue to load (i.e. not force a reload). If it has already loaded successfully, the completion block will be invoked right away. If it has already failed to load, the completion block will be invoked right away with error previously encountered. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100
See also
- cancelLoad to cancel loading
- retryLoadWithCompletion: to force reload

◆ onLoadStatusChanged

- (void) onLoadStatusChanged

Never call this method directly. The framework calls this method on a background thread when AGSLoadable::loadStatus changes is called. Subclasses can optionally implement this to know when their loading status has changed.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ retryLoadWithCompletion:

- (void) retryLoadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Tries to reload when an object has failed to load. This method should be called judiciously. It should be called when:

  1. you didn't have network connectivity earlier when it failed and you want to retry now that you have connectivity
  2. the server was down earlier when it failed and you want to retry
  3. the request is taking too long and you want to cancel it and retry, in which case you will first call cancelLoad and then this method

If the data hasn't started loading, it will start loading. If it is already loading, it will just continue to load. If it has already loaded successfully, calls back right away. If it has already failed to load, tries again. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100

Property Documentation

◆ expression

- (AGSArcadeExpression*) expression
readnonatomicstrong

The Arcade expression of the Arcade evaluator.

Since
100.14

◆ loadError

- (NSError*) loadError
readnonatomicstronginherited

The error that was encountered during the most recent load operation. Will be nil if the operation succeeded.

Since
100

◆ loadStatus

- (AGSLoadStatus) loadStatus
readrequirednonatomicassigninherited

Status of the load operation.

Since
100

◆ profile

- (AGSArcadeProfile) profile
readnonatomicassign

The Arcade profile under which the expression should evaluate.

Since
100.14

◆ profileVariablesUsed

- (NSArray<NSString *>*) profileVariablesUsed
readnonatomiccopy

Return an array of the strings containing the names of all profile variable used in the script.

Since
100.14

◆ stable

- (BOOL) stable
readnonatomicassign

If the script is considered stable.

A script is considered stable if the script will return the same result given the same inputs. There are certain functions listed below that will return different values on each evaluation. Use of these functions means the script is not considered stable.

Arcade functions that stop a script being considered stable:

  • Now.
  • Today.
  • TimeStamp.
  • Random.
  • Guid.
  • NextSequence.
    Since
    100.14