对成员 OCKCarePlanActivity 评估的引用不明确

Ambiguous reference to member OCKCarePlanActivity 'assessment

使用 Xcode 9.4、Swift 3 和 CareKit 框架 1.2.1 错误消息:

Ambiguous reference to member OCKCarePlanActivity 'assessment (withIdentifier:groupIdentifier:title:text:tintColor:resultResettable:schedule:userInfo:thresholds:optional:)'

这是代码。

    let pulseActivity = OCKCarePlanActivity
            .assessment(withIdentifier: ActivityIdentifier.pulse.rawValue,
                        groupIdentifier: nil,
                        title: "Pulse",
                        text: "Do you have one?",
                        tintColor: UIColor.darkGreen(),
                        resultResettable: true,
                        schedule: CarePlanData.dailyScheduleRepeating(occurencesPerDay: 1),
                        userInfo: ["ORKTask": AssessmentTaskFactory.makePulseAssessmentTask()]
)

较新的 CareKit 框架添加了可选参数。

let pulseActivity = OCKCarePlanActivity
        .assessment(withIdentifier: ActivityIdentifier.pulse.rawValue,
                    groupIdentifier: nil,
                    title: "Pulse",
                    text: "Do you have one?",
                    tintColor: UIColor.darkGreen(),
                    resultResettable: true,
                    schedule: CarePlanData.dailyScheduleRepeating(occurencesPerDay: 1),
                    userInfo: ["ORKTask": AssessmentTaskFactory.makePulseAssessmentTask()],
                    optional: true) //--> NEW

此更改修复了我的错误。希望对其他人有帮助。