CoreData iPad 应用程序崩溃

发布于 2024-10-04 21:53:32 字数 230 浏览 1 评论 0原文

我使用 CoreData 制作了一个新的分割视图 iPad 应用程序。我所做的只是向实体添加一个新属性,它是一个字符串。 (默认为时间戳、日期)。

这会导致应用程序在启动时仅添加它就会崩溃。为什么会这样呢?

例如,我打算用它来显示文本而不是默认日期。例如更改这一行: [newManagedObject setValue:[NSDate date] forKey:@"timeStamp"];使用日期以外的不同值。

I have made a new split view iPad app using CoreData. All I have done is added a new attribute to the entity which is a string. (The default being timeStamp, date).

This causes the app to crash upon startup just adding it. Why is this so?

I was for example going to play around with it to display text rather than its default date. E.g. changing this line: [newManagedObject setValue:[NSDate date] forKey:@"timeStamp"]; Using a different value other than a date.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿看小鸭子会跑 2024-10-11 21:53:32

几乎可以肯定,因为您已经在设备上安装了应用程序,现在您已经更改了核心数据模型,现有数据库的结构错误。您可以通过在崩溃后查看 XCode 控制台窗口来确认这一点:您应该看到异常堆栈跟踪,并且在其上方显示一条消息,内容为“用于打开商店的模型与用于创建商店的模型不兼容”。店铺。”当 XCode 将应用程序的修改版本安装到设备上时,它不会自动覆盖现有数据库,这很痛苦并且经常让我感到困惑;-)

在对数据库进行任何更改后,您必须从设备上卸载应用程序核心数据模型,以便它以干净版本的数据库开始。有 有关核心数据这方面的更多信息,请访问 Shannon Appelcline 的 iPhone in Action 网站。

It's almost certainly because you already had the app installed on the device, and now that you have changed the Core Data model the existing database has the wrong structure. You can confirm this by looking in the XCode console window after the crash: you should see an exception stack trace and, above that, a message along the lines of "The model used to open the store is incompatible with the one used to create the store." When XCode installs your modified version of the app onto the device, it doesn't overwrite the existing database automatically, which is a pain and regularly catches me out ;-)

You have to uninstall the app from the device after making any changes to the Core Data model, so that it starts with a clean version of the database. There's more info about this aspect of Core Data at Shannon Appelcline's iPhone in Action site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文