删除旧的 Coredata 类并添加新的类会导致 iOS 崩溃

发布于 2024-12-24 00:25:00 字数 444 浏览 5 评论 0原文

我最近从 Xcode 3.2 切换到 4.2。我删除了 Coredata 模型中的一些实体以及在 3.2 版本中创建的与其关联的类。我再次添加了相同的实体,并为这些实体创建了新的 NSManagedObject 类。现在我的应用程序崩溃了,没有任何错误消息。但我非常确定它在尝试创建 Coredata 对象时会崩溃。甚至我的project.sqlite也没有被创建。我希望我可以在这里发布一些代码片段...但是,我并不完全知道问题区域...任何人都可以帮助我解决这个问题...

经过一些调试后我发现该应用程序在以下行崩溃

MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = appDelegate.managedObjectContext;

I have recently shifted from Xcode 3.2 to 4.2. I have deleted some entities in my Coredata model and also the classes associated with it which were created in 3.2 version.I have added the same entities ones again and created new NSManagedObject classes for those entities. Now my app is getting crashed with out any error messages. But i am pretty sure that it is getting crashed while trying to create the Coredata objects. Even my project.sqlite is also not getting created .I wish i could post some code snippets here... But, i dont exactly know the problem area... Can anyone help me with this....

After some debugging i found that the app is getting crashed at the following line

MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = appDelegate.managedObjectContext;

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

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

发布评论

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

评论(1

漫雪独思 2024-12-31 00:25:00

如果您仍处于开发阶段,请清理您的项目,从 iPhone(或模拟器,使用相同的触摸并按住手势)中删除应用程序,然后再次运行它。这将从应用程序数据中删除您的数据库。

如果您已经发布了您的应用程序并希望允许您的用户保留他们的数据,您将需要了解如何执行 迁移

If you are still in the development phase, clean your project, remove your application from the iPhone (or the simulator, using the same touch and hold gesture), and run it again. This will have removed your database from the application data.

If you already have published your application and want to allow your users to keep their data, you will need to look at how to do a migration.

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