Apple CareKit store crases 拯救病人:无效的核心数据 URI

问题描述

所以我正在尝试设置一个简单的护理套件应用。

我创建了一个商店包装

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'

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

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)