处理CoreData和可选类型的目标C中的新特性

发布于 2025-02-10 21:25:53 字数 217 浏览 1 评论 0原文

我与Coredata合作,提出了一些我无法通过研究回答的问题。假设我已经开发了一个应用程序,并且使用Coredata进行持续存储。现在,我想更新该应用程序并将属性添加到实体。我认为最好的解决方案是使新属性可选,以使现有实例没有问题,您是否同意?另一件事是,当我尝试时,我注意到INT16?不允许,因为它与Objective-C不起作用。但是作为替代方案,nsnumber?作品,我不喜欢它。您如何做,最佳实践是什么样的?

I work with CoreData and I came up with some questions that I could not answer through research. Let's assume I have developed an app and the persistent storage is done with CoreData. Now I want to update the app and add a property to an entity. I think the best solution is to make the new property optional so that there are no problems with the existing instances, do you agree? Another thing is that when I try, I noticed the int16? not allowed because it does not work with objective-c. But as an alternative, NSNumber? works, which I somehow don't like. How do you do it and what does the best practice look like?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文