0

現在、調査キットを使用してアプリを構築しています。以下は私の質問です。

let onsetQuestionStepTitle = "Title"
let onsetQuestionStepQuestion = "Question Name"
let onsetTextChoices = [
    ORKTextChoice(text: "superb", value: 0 as NSCoding & NSCopying & NSObjectProtocol),
    ORKTextChoice(text: "great", value: 1 as NSCoding & NSCopying & NSObjectProtocol),
    ORKTextChoice(text: "fair", value: 2 as NSCoding & NSCopying & NSObjectProtocol),
    ORKTextChoice(text: "not good", value: 3 as NSCoding & NSCopying & NSObjectProtocol),
    ORKTextChoice(text: "bad", value: 4 as NSCoding & NSCopying & NSObjectProtocol)
]
let onsetAnswerFormat: ORKTextChoiceAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: onsetTextChoices)
let onsetQuestionStep = ORKQuestionStep(identifier: "twoAwakeSurvey", title: onsetQuestionStepTitle, question: onsetQuestionStepQuestion, answer: onsetAnswerFormat)
steps += [onsetQuestionStep]

ユーザーが「素晴らしい」をタップした場合は、「threeAwakeSurvey」という識別子を使用して次のステップにスキップし、「fourAwakeSurvey」に進みます。そのために、以下のコードを実装しました。

var task = ORKNavigableOrderedTask(identifier: "StepNavigationTaskIdentifier", steps: steps)
let resultSelector: ORKResultSelector = ORKResultSelector(resultIdentifier: "twoAwakeSurvey")
let askLocation = ORKResultPredicate.predicateForChoiceQuestionResult(with: resultSelector, expectedAnswerValue: 0 as NSCoding & NSCopying & NSObjectProtocol)

let locationNavigationRule = ORKPredicateSkipStepNavigationRule(resultPredicate: askLocation)
task.setSkip(locationNavigationRule, forStepIdentifier: "threeAwakeSurvey")

ただし、これは機能していません。ドキュメントを読みましたが、まだ理由がわかりません。

4

1 に答える 1