0

所以我正在尝试建立一个简单的护理工具包应用程序。

我创建了一个商店包装器

import Foundation
import CareKitStore

struct CareKitStore {
    static let shared = CareKitStore()
    
    let store: OCKStore
    
    init(inMemory:Bool = false) {
        if (inMemory) {
            store = OCKStore(name: "in-memory", type: .inMemory)
            //TODO Sample data into store
        } else {
            store = OCKStore(name: "com.whitewhiskywolf.medminder.carekit")
        }
    }
    
    func savePatient(givenName: String, familyName: String) {
        let patient = OCKPatient(id: UUID().uuidString, givenName: givenName, familyName: familyName)
        let carePlan = OCKCarePlan(id: "Patient Plan", title: UUID().uuidString, patientID: OCKLocalVersionID(patient.id))
        store.addPatient(patient)
        store.addCarePlan(carePlan)
    }
} 

当调用保存患者时,我遇到了崩溃terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The specified URI is not a valid Core Data URI: E3730728-73D1-4EB3-AEC2-6DD34CDADEE8'

我不知道我在这里做错了什么。

编辑:当应用程序重新启动时,我也会寻找患者,并且它能够查询。

4

0 回答 0