ORKPredicateStepNavigationRule Class Reference

Inherits from ORKStepNavigationRule : NSObject
Declared in ORKStepNavigationRule.h

The ORKPredicateStepNavigationRule can be used to match any answer combination in the results of the ongoing task (or in those of previously completed tasks) and jump accordingly. You must provide one or more result predicates (each predicate can match one or more step results within the task).

Predicate step navigation rules contain an arbitrary number of result predicates with a corresponding number of destination step identifiers, plus an optional default step identifier that is used if none of the result predicates match. One result predicate can match one or more question results; if matching several question results, that predicate can belong to the same or to different task results). This rule allows you to define arbitrarily complex task navigation behaviors.

The ORKResultPredicate class provides convenience class methods to build predicates for all the ORKQuestionResult subtypes. Predicates must supply both the task result identifier and the question result identifier, in addition to one or more expected answers.

Other Methods

– initWithResultPredicates:destinationStepIdentifiers:defaultStepIdentifier:

Returns an initialized predicate step navigation rule using the specified result predicates, destination step identifiers, and an optional default step identifier.

- (instancetype)initWithResultPredicates:(NSArray<NSPredicate*> *)resultPredicates destinationStepIdentifiers:(NSArray<NSString*> *)destinationStepIdentifiers defaultStepIdentifier:(nullable NSString *)defaultStepIdentifier

Parameters

resultPredicates

An array of result predicates. Each result predicate can match one or more question results in the ongoing task result or in any of the additional task results.

destinationStepIdentifiers

An array of possible destination step identifiers. This array must contain one step identifier for each of the predicates in the result predicates parameters. If you want for a certain predicate match to end te task, you achieve that by using the ORKNullStepIdentifier constant.

defaultStepIdentifier

The identifier of the step, which is used if none of the result predicates match. If this argument is nil and none of the predicates match, the default ordered task navigation behavior takes place (that is, the task goes to the next step in order).

Return Value

An initialized predicate step navigation rule.

Declared In

ORKStepNavigationRule.h

– initWithResultPredicates:destinationStepIdentifiers:

Returns an initialized predicate step navigation rule using the specified result predicates and destination step identifiers.

- (instancetype)initWithResultPredicates:(NSArray<NSPredicate*> *)resultPredicates destinationStepIdentifiers:(NSArray<NSString*> *)destinationStepIdentifiers

Parameters

resultPredicates

An array of result predicates. Each result predicate can match one or more question results in the ongoing task result or in any of the additional task results.

destinationStepIdentifiers

An array of possible destination step identifiers. This array must contain one step identifier for each of the predicates in the result predicates parameters.

Return Value

An initialized predicate step navigation rule.

Declared In

ORKStepNavigationRule.h

– initWithCoder:

Returns a new predicate step navigation rule that was initialized from data in the given unarchiver.

- (instancetype)initWithCoder:(NSCoder *)aDecoder

Parameters

aDecoder

The coder from which to initialize the step navigation rule.

Return Value

A new predicate step navigation rule.

Declared In

ORKStepNavigationRule.h

  additionalTaskResults

An optional array of additional task results.

@property (nonatomic, copy, nullable) NSArray<ORKTaskResult*> *additionalTaskResults

Discussion

With this property, a task can have different navigation behavior depending on the results of related tasks that the user may have already completed. The predicate step navigation rule can use the question results within these tasks, in addition to the current task question results, to match the result predicates.

You must ensure that all the task result identifiers are unique and that they are different from the ongoing task result identifier. Also ensure that no task result contains question results with duplicate identifiers. Question results can have equal identifiers provided that they belong to different task results.

Each object in the array should be of the ORKTaskResult class.

Declared In

ORKStepNavigationRule.h

  resultPredicates

The array of result predicates.

@property (nonatomic, copy, readonly) NSArray<NSPredicate*> *resultPredicates

Discussion

This property contains one result predicate for each of the step identifiers in the destinationStepIdentifiers property.

Declared In

ORKStepNavigationRule.h

  destinationStepIdentifiers

The array of destination step identifiers. It contains one step identifier for each of the predicates in the resultPredicates parameter.

@property (nonatomic, copy, readonly) NSArray<NSString*> *destinationStepIdentifiers

Declared In

ORKStepNavigationRule.h

  defaultStepIdentifier

The identifier of the step that is used if none of the result predicates match.

@property (nonatomic, copy, readonly, nullable) NSString *defaultStepIdentifier

Declared In

ORKStepNavigationRule.h

Extension Methods

– initWithResultPredicates:destinationStepIdentifiers:defaultStepIdentifier:validateArrays:

Returns an initialized predicate step navigation rule using the specified result predicates, destination step identifiers, and an optional default step identifier.

- (instancetype)initWithResultPredicates:(NSArray<NSPredicate*> *)resultPredicates destinationStepIdentifiers:(NSArray<NSString*> *)destinationStepIdentifiers defaultStepIdentifier:(nullable NSString *)defaultStepIdentifier validateArrays:(BOOL)validateArrays

Parameters

resultPredicates

An array of result predicates. Each result predicate can match one or more step results in the ongoing task.

destinationStepIdentifiers

An array of possible destination step identifiers. This array must contain one step identifier for each of the predicates in the resultPredicates parameter.

defaultStepIdentifier

The identifier of the step which is used if none of the result predicates match. If this argument is nil and none of the predicates match, the default ordered task navigation behavior takes place (that is, the task goes to the next step in order).

validateArrays

YES to throw an exception if result predicates or destination step identifiers are nil or empty; NO to skip their validation.

Return Value

An initialized predicate step navigation rule.

Declared In

ORKStepNavigationRule_Private.h