gpt4 book ai didi

swift - 如何修复 loadPersistentStores 在加载时崩溃

转载 作者:搜寻专家 更新时间:2023-11-01 05:32:16 24 4
gpt4 key购买 nike

我正在尝试在 Xcode 上开发一个使用核心数据的应用程序,但是,当我提交该应用程序进行测试审查时,它在他们的模拟器上崩溃了,但在我的模拟器上却没有。这是怎么回事?

对于初学者来说,我最近完成了一个应用程序的制作,该应用程序需要一段时间才能开发并将其提交到 iTunes connect。我的应用程序被拒绝,因为“我们无法审查您的应用程序,因为它在启动时崩溃了”。我收到并符号化了发生崩溃的那一行。

https://imgur.com/a/3iX6pqc

崩溃发生在我的 App Delegate 中的第 81 行,正是我获取持久容器并将其加载的位置。

https://imgur.com/EzQvnSQ

    lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "AlarmSavedData")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in

if let error = error as NSError? {
print("Here!")
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.



/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")

}
})
return container
}()

我希望本地数据库能够很好地为他们加载,但出于某种原因,我是数据库加载的唯一对象。我可以使用它,但是当 Apple Review 团队尝试运行它时,它崩溃了。关于正在发生的事情以及如何解决它的任何想法?目标是让每个用户都有自己的本地数据库,使用核心数据来存储他们创建的数据。

崩溃日志:https://imgur.com/a/rx9doSR

最佳答案

尝试重置模拟器。这对我来说是固定的:

enter image description here

关于swift - 如何修复 loadPersistentStores 在加载时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55458231/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com