ArcGIS Runtime SDK for iOS
100.15
|
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:
AGSArcadeEvaluator
object using AGSArcadeExpression
and AGSArcadeProfile
. evaluateWithProfileVariables:completion: (AGSArcadeEvaluator)
AGSArcadeEvaluationResult
.From an AGSArcadeEvaluator
object you can query information to determine,
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:
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.
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 | |
AGSArcadeExpression * | expression |
NSError * | loadError |
AGSLoadStatus | loadStatus |
AGSArcadeProfile | profile |
NSArray< NSString * > * | profileVariablesUsed |
BOOL | stable |
+ (instancetype) arcadeEvaluatorWithExpression: | (AGSArcadeExpression *) | expression | |
profile: | (AGSArcadeProfile) | profile | |
Creates an AGSArcadeEvaluator
object.
expression | The Arcade expression to be evaluated. |
profile | The Arcade profile under which the expression will be evaluated. |
- (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.
variableName | The name of the profile variable whose used attributes are required. |
featureTableSource | A AGSFeatureTable from which we can obtain a list of all attributes names for the profile variable. |
completion | Block that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated. |
- (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.
variableName | The name of the profile variable whose used attributes are required. |
geoElementSource | A AGSGeoElement from which we can obtain a list of all attributes names for the profile variable. |
completion | Block that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated. |
|
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
- (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
.
Provided by category AGSLoadableBase(ForSubclassEyesOnly).
- (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.
retrying | flag that is true if this method was called from retryLoadWithCompletion: (AGSLoadable-p) . |
Provided by category AGSLoadableBase(ForSubclassEyesOnly).
- (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:
NSString
. BOOL
NSDate
AGSGeometry
AGSGeoElement
(or anything derived from it such as AGSFeature
, AGSENCFeature
) AGSFeatureTable
, see AGSFeatureTableType
. NSDictionary
, String to supported type. AGSGeodatabase
AGSServiceGeodatabase
AGSGeoModel
(or anything derived from it such as AGSMap
or AGSScene
). AGSLocation
.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. profileVariables | The profile variables for the script as key/value pairs. |
completion | Block that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated. |
- (instancetype) initWithExpression: | (AGSArcadeExpression *) | expression | |
profile: | (AGSArcadeProfile) | profile | |
Creates an AGSArcadeEvaluator
object.
expression | The Arcade expression to be evaluated. |
profile | The Arcade profile under which the expression will be evaluated. |
- (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.
Provided by category AGSLoadableBase(ForSubclassEyesOnly).
|
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.
completion | block that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load. |
- cancelLoad
to cancel loading - retryLoadWithCompletion:
to force reload - (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.
Provided by category AGSLoadableBase(ForSubclassEyesOnly).
|
requiredinherited |
Tries to reload when an object has failed to load. This method should be called judiciously. It should be called when:
cancelLoad
and then this methodIf 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.
completion | block that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load. |
|
readnonatomicstrong |
The Arcade expression of the Arcade evaluator.
|
readnonatomicstronginherited |
The error that was encountered during the most recent load operation. Will be nil if the operation succeeded.
|
readrequirednonatomicassigninherited |
Status of the load operation.
|
readnonatomicassign |
The Arcade profile under which the expression should evaluate.
|
readnonatomiccopy |
Return an array of the strings containing the names of all profile variable used in the script.
|
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: