ORKResultPredicate Class Reference

Inherits from NSObject
Declared in ORKResultPredicate.h

The ORKResultPredicate class provides convenience class methods to build predicates for most of the ORKQuestionResult subtypes.

You use result predicates to create ORKPredicateStepNavigationRule objects. The result predicates are used to match specific ORKQuestionResult instances (created in response to the participant’s answers) and navigate accordingly. You can match results both in an ongoing task or in previously completed tasks.

You chose which question result to match by using an ORKResultSelector object.

Note that each ORKStep object produces one ORKStepResult collection object. A step result produced by an ORKQuestionStep object contains one ORKQuestionResult object which has

the same identifier as the step that generated it. A step result produced by an ORKFormStep object can contain one or more ORKQuestionResult objects that have the identifiers of the ORKFormItem objects that generated them.

For matching a single-question step result, you only need to set the resultIdentifier when building the result selector object. The stepIdentifier will take the same value.

For matching a form item result, you need to build a result selector with a stepIdentifier (the form step identifier) and a resultIdentifier (the form item result identifier).

For matching results in the ongoing task, leave the taskIdentifier in the the form step identifier as nil. For matching results in different tasks, set the taskIdentifier appropriately.

+ predicateForNilQuestionResultWithResultSelector:

Returns a predicate matching a result of the kind ORKQuestionResult whose answer is nil. A question result has a nil answer if it was generated by a step that was skipped by the user or if it was part of a form step and the question was left unanswered.

+ (NSPredicate *)predicateForNilQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForScaleQuestionResultWithResultSelector:expectedAnswer:

Returns a predicate matching a result of type ORKScaleQuestionResult whose answer is the specified integer value.

+ (NSPredicate *)predicateForScaleQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector expectedAnswer:(NSInteger)expectedAnswer

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

expectedAnswer

The expected integer value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForScaleQuestionResultWithResultSelector:minimumExpectedAnswerValue:maximumExpectedAnswerValue:

Returns a predicate matching a result of type ORKScaleQuestionResult whose answer is within the specified double values.

+ (NSPredicate *)predicateForScaleQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector minimumExpectedAnswerValue:(double)minimumExpectedAnswerValue maximumExpectedAnswerValue:(double)maximumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

minimumExpectedAnswerValue

The minimum expected double value. Pass ORKIgnoreDoubleValue if you don’t want to compare the answer against a maximum double value.

maximumExpectedAnswerValue

The maximum expected double value. Pass ORKIgnoreDoubleValue if you don’t want to compare the answer against a maximum double value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForScaleQuestionResultWithResultSelector:minimumExpectedAnswerValue:

Returns a predicate matching a result of type ORKScaleQuestionResult whose answer is greater than or equal to the specified double value.

+ (NSPredicate *)predicateForScaleQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector minimumExpectedAnswerValue:(double)minimumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

minimumExpectedAnswerValue

The minimum expected double value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForScaleQuestionResultWithResultSelector:maximumExpectedAnswerValue:

Returns a predicate matching a result of type ORKScaleQuestionResult whose answer is less than or equal to the specified double value.

+ (NSPredicate *)predicateForScaleQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector maximumExpectedAnswerValue:(double)maximumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

maximumExpectedAnswerValue

The maximum expected double value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForChoiceQuestionResultWithResultSelector:expectedAnswerValue:

Returns a predicate matching a result of type ORKChoiceQuestionResult whose answer is equal to the specified object.

+ (NSPredicate *)predicateForChoiceQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector expectedAnswerValue:(id<NSCopying,NSCoding,NSObject>)expectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

expectedAnswerValue

The expected answer object.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForChoiceQuestionResultWithResultSelector:expectedAnswerValues:

Returns a predicate matching a result of type ORKChoiceQuestionResult whose answers are equal to the specified objects.

+ (NSPredicate *)predicateForChoiceQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector expectedAnswerValues:(NSArray<id<NSCopying,NSCoding,NSObject> > *)expectedAnswerValues

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

expectedAnswerValues

An array with a some or of all of the expected answer objects.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForChoiceQuestionResultWithResultSelector:matchingPattern:

Returns a predicate matching a result of type ORKChoiceQuestionResult whose answer matches the specified regular expression pattern. This predicate can solely be used to match choice results which only contain string answers.

+ (NSPredicate *)predicateForChoiceQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector matchingPattern:(NSString *)pattern

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

pattern

An ICU-compliant regular expression pattern that matches the answer string.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForChoiceQuestionResultWithResultSelector:matchingPatterns:

Returns a predicate matching a result of type ORKChoiceQuestionResult whose answers match the specified regular expression patterns.

+ (NSPredicate *)predicateForChoiceQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector matchingPatterns:(NSArray<NSString*> *)patterns

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

patterns

An array of ICU-compliant regular expression patterns that match the answer strings.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForBooleanQuestionResultWithResultSelector:expectedAnswer:

Returns a predicate matching a result of type ORKBooleanQuestionResult whose answer is the specified Boolean value.

+ (NSPredicate *)predicateForBooleanQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector expectedAnswer:(BOOL)expectedAnswer

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

expectedAnswer

The expected boolean value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForTextQuestionResultWithResultSelector:expectedString:

Returns a predicate matching a result of type ORKTextQuestionResult whose answer is equal to the specified string.

+ (NSPredicate *)predicateForTextQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector expectedString:(NSString *)expectedString

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

expectedString

The expected result string.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForTextQuestionResultWithResultSelector:matchingPattern:

Returns a predicate matching a result of type ORKTextQuestionResult whose answer matches the specified regular expression pattern.

+ (NSPredicate *)predicateForTextQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector matchingPattern:(NSString *)pattern

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

pattern

An ICU-compliant regular expression pattern that matches the answer string.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForNumericQuestionResultWithResultSelector:expectedAnswer:

Returns a predicate matching a result of type ORKNumericQuestionResult whose answer is the specified integer value.

+ (NSPredicate *)predicateForNumericQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector expectedAnswer:(NSInteger)expectedAnswer

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

expectedAnswer

The expected integer value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForNumericQuestionResultWithResultSelector:minimumExpectedAnswerValue:maximumExpectedAnswerValue:

Returns a predicate matching a result of type ORKNumericQuestionResult whose answer is within the specified double values.

+ (NSPredicate *)predicateForNumericQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector minimumExpectedAnswerValue:(double)minimumExpectedAnswerValue maximumExpectedAnswerValue:(double)maximumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

minimumExpectedAnswerValue

The minimum expected double value. Pass ORKIgnoreDoubleValue if you don’t want to compare the answer against a maximum double value.

maximumExpectedAnswerValue

The maximum expected double value. Pass ORKIgnoreDoubleValue if you don’t want to compare the answer against a minimum double value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForNumericQuestionResultWithResultSelector:minimumExpectedAnswerValue:

Returns a predicate matching a result of type ORKNumericQuestionResult whose answer is greater than or equal to the specified double value.

+ (NSPredicate *)predicateForNumericQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector minimumExpectedAnswerValue:(double)minimumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

minimumExpectedAnswerValue

The minimum expected double value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForNumericQuestionResultWithResultSelector:maximumExpectedAnswerValue:

Returns a predicate matching a result of type ORKNumericQuestionResult whose answer is less than or equal to the specified double value.

+ (NSPredicate *)predicateForNumericQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector maximumExpectedAnswerValue:(double)maximumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

maximumExpectedAnswerValue

The maximum expected double value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForTimeOfDayQuestionResultWithResultSelector:minimumExpectedHour:minimumExpectedMinute:maximumExpectedHour:maximumExpectedMinute:

Returns a predicate matching a result of type ORKTimeOfDayQuestionResult whose answer is within the specified hour and minute values.

+ (NSPredicate *)predicateForTimeOfDayQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector minimumExpectedHour:(NSInteger)minimumExpectedHour minimumExpectedMinute:(NSInteger)minimumExpectedMinute maximumExpectedHour:(NSInteger)maximumExpectedHour maximumExpectedMinute:(NSInteger)maximumExpectedMinute

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

minimumExpectedHour

The minimum expected hour component value.

minimumExpectedMinute

The minimum expected minute component value.

maximumExpectedHour

The maximum integer hour component value.

maximumExpectedMinute

The maximum expected minute component value.

Return Value

A result predicate.

Discussion

Note that ORKTimeOfDayQuestionResult internally stores its answer as an NSDateComponents object. If you are interested in additional components, you must build the predicate manually.

Declared In

ORKResultPredicate.h

+ predicateForTimeIntervalQuestionResultWithResultSelector:minimumExpectedAnswerValue:maximumExpectedAnswerValue:

Returns a predicate matching a result of type ORKTimeIntervalQuestionResult whose answer is within the specified NSTimeInterval values.

+ (NSPredicate *)predicateForTimeIntervalQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector minimumExpectedAnswerValue:(NSTimeInterval)minimumExpectedAnswerValue maximumExpectedAnswerValue:(NSTimeInterval)maximumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

minimumExpectedAnswerValue

The minimum expected NSTimeInterval value. Pass ORKIgnoreTimeIntervlValue if you don’t want to compare the answer against a maximum NSTimeInterval value.

maximumExpectedAnswerValue

The maximum expected NSTimeInterval value. Pass ORKIgnoreTimeIntervlValue if you don’t want to compare the answer against a minimum NSTimeInterval value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForTimeIntervalQuestionResultWithResultSelector:minimumExpectedAnswerValue:

Returns a predicate matching a result of type ORKTimeIntervalQuestionResult whose answer is the specified integer value.

+ (NSPredicate *)predicateForTimeIntervalQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector minimumExpectedAnswerValue:(NSTimeInterval)minimumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

minimumExpectedAnswerValue

The minimum expected NSTimeInterval value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForTimeIntervalQuestionResultWithResultSelector:maximumExpectedAnswerValue:

Returns a predicate matching a result of type ORKTimeIntervalQuestionResult whose answer is the specified integer value.

+ (NSPredicate *)predicateForTimeIntervalQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector maximumExpectedAnswerValue:(NSTimeInterval)maximumExpectedAnswerValue

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

maximumExpectedAnswerValue

The maximum expected NSTimeInterval value.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForDateQuestionResultWithResultSelector:minimumExpectedAnswerDate:maximumExpectedAnswerDate:

Returns a predicate matching a result of type ORKDateQuestionResult whose answer is a date within the specified dates.

+ (NSPredicate *)predicateForDateQuestionResultWithResultSelector:(ORKResultSelector *)resultSelector minimumExpectedAnswerDate:(nullable NSDate *)minimumExpectedAnswerDate maximumExpectedAnswerDate:(nullable NSDate *)maximumExpectedAnswerDate

Parameters

resultSelector

The result selector object which specifies the question result you are interested in.

minimumExpectedAnswerDate

The minimum expected date. Pass nil if you don’t want to compare the answer against a minimum date.

maximumExpectedAnswerDate

The maximum expected date. Pass nil if you don’t want to compare the answer against a maximum date.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h

+ predicateForConsentWithResultSelector:didConsent:

Returns a predicate matching a result of type ORKConsentSignatureResult whose consented value matches the specified boolean value.

+ (NSPredicate *)predicateForConsentWithResultSelector:(ORKResultSelector *)resultSelector didConsent:(BOOL)didConsent

Parameters

resultSelector

The result selector object which specifies the question result you are interested in. Note that when creating this result selector you must provide the desired step identifier as the stepIdentifier argument and the corresponding signature identifier as the resultIdentifier argument). The step identifier will normally refer to the result of a ORKConsentReviewStep and the signature identifier will refer to the contained ORKConsentSignatureResult corresponding to the signature collected by the consent review step.

Return Value

A result predicate.

Declared In

ORKResultPredicate.h