1. <tfoot id='9MLGO'></tfoot>
  2. <legend id='9MLGO'><style id='9MLGO'><dir id='9MLGO'><q id='9MLGO'></q></dir></style></legend>
  3. <i id='9MLGO'><tr id='9MLGO'><dt id='9MLGO'><q id='9MLGO'><span id='9MLGO'><b id='9MLGO'><form id='9MLGO'><ins id='9MLGO'></ins><ul id='9MLGO'></ul><sub id='9MLGO'></sub></form><legend id='9MLGO'></legend><bdo id='9MLGO'><pre id='9MLGO'><center id='9MLGO'></center></pre></bdo></b><th id='9MLGO'></th></span></q></dt></tr></i><div id='9MLGO'><tfoot id='9MLGO'></tfoot><dl id='9MLGO'><fieldset id='9MLGO'></fieldset></dl></div>
    • <bdo id='9MLGO'></bdo><ul id='9MLGO'></ul>
    1. <small id='9MLGO'></small><noframes id='9MLGO'>

      Swift - 在应用程序组中共享核心数据模型(带扩展)

      Swift - Sharing Core Data Model in App Group (w/ extension)(Swift - 在应用程序组中共享核心数据模型(带扩展))
      <tfoot id='jBAI2'></tfoot>
        <bdo id='jBAI2'></bdo><ul id='jBAI2'></ul>

        1. <i id='jBAI2'><tr id='jBAI2'><dt id='jBAI2'><q id='jBAI2'><span id='jBAI2'><b id='jBAI2'><form id='jBAI2'><ins id='jBAI2'></ins><ul id='jBAI2'></ul><sub id='jBAI2'></sub></form><legend id='jBAI2'></legend><bdo id='jBAI2'><pre id='jBAI2'><center id='jBAI2'></center></pre></bdo></b><th id='jBAI2'></th></span></q></dt></tr></i><div id='jBAI2'><tfoot id='jBAI2'></tfoot><dl id='jBAI2'><fieldset id='jBAI2'></fieldset></dl></div>
            <legend id='jBAI2'><style id='jBAI2'><dir id='jBAI2'><q id='jBAI2'></q></dir></style></legend>
          • <small id='jBAI2'></small><noframes id='jBAI2'>

                <tbody id='jBAI2'></tbody>
                本文介绍了Swift - 在应用程序组中共享核心数据模型(带扩展)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试在我的应用程序和扩展程序中使用相同的核心数据模型,但不确定如何在两者之间共享核心数据模型.核心数据模型的类使用带有类名的命名空间,所以当我尝试获取扩展中的对象时,我得到了无法加载名为"的类的错误.

                I'm trying to use the same core data model in my app as well as an extension, but am unsure how to share the core data model between the 2. The class for the core data model uses a namespace with the classname, so when I try and fetch the objects in the extension I get the unable to load class named "" error.

                CoreData:警告:无法为实体加载名为Dali.Alarm"的类'警报'.找不到类,改用默认的 NSManagedObject.

                CoreData: warning: Unable to load class named 'Dali.Alarm' for entity 'Alarm'. Class not found, using default NSManagedObject instead.

                有没有办法在类名中不使用命名空间,或者有没有办法让扩展继承主项目的命名空间?

                Is there anyway to not use a namespace in the classname, or is there a way to make the extension inherit the namespace of the main project?

                推荐答案

                我之前被卡住了.似乎是一个真正的问题,将其作为功能请求/错误提交给 Apple 并没有什么坏处.

                I was stuck on this earlier. Seems like a real issue, and it wouldn't hurt to file it as a feature request/bug with Apple.

                与此同时,您可以通过两个步骤绕过它.首先,用 @objc(ClassName) 标记你的 NSManagedObject 子类.只需将其插入类声明上方:

                In the meantime, you can get around it with two steps. First, tag your NSManagedObject subclasses with @objc(ClassName). Simply insert it above the class declaration:

                @objc(ClassName)
                class ClassName: NSManagedObjectSubclass {
                    @NSManaged var name : String
                }
                

                其次,返回托管对象模型,并从您正在使用的实体的检查器中的类"名称字段中删除命名空间.

                Second, go back to the managed object model, and remove the namespace from the "class" name field in the inspector for the Entity you're working with.

                今天这对我有用,在阅读以下内容后:我无法在 Swift 项目的两个目标中使用我的核心数据模型

                This worked for me today, after reading this: I can't use my core data model in two targets in a Swift project

                这篇关于Swift - 在应用程序组中共享核心数据模型(带扩展)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                How to format localised strings in Swift?(如何在 Swift 中格式化本地化字符串?)
                Why do we need to set delegate to self? Why isn#39;t it defaulted by the compiler?(为什么我们需要将委托设置为自我?为什么编译器不默认它?)
                set delegate and datasource of uitableview programmatically in Swift(在 Swift 中以编程方式设置 uitableview 的委托和数据源)
                Swift delegate beetween two VC without segue(两个没有 segue 的 VC 之间的 Swift 委托)
                Swift can#39;t call protocol method via delegate(Swift 不能通过委托调用协议方法)
                  <i id='CJXW5'><tr id='CJXW5'><dt id='CJXW5'><q id='CJXW5'><span id='CJXW5'><b id='CJXW5'><form id='CJXW5'><ins id='CJXW5'></ins><ul id='CJXW5'></ul><sub id='CJXW5'></sub></form><legend id='CJXW5'></legend><bdo id='CJXW5'><pre id='CJXW5'><center id='CJXW5'></center></pre></bdo></b><th id='CJXW5'></th></span></q></dt></tr></i><div id='CJXW5'><tfoot id='CJXW5'></tfoot><dl id='CJXW5'><fieldset id='CJXW5'></fieldset></dl></div>
                  <legend id='CJXW5'><style id='CJXW5'><dir id='CJXW5'><q id='CJXW5'></q></dir></style></legend>
                  1. <small id='CJXW5'></small><noframes id='CJXW5'>

                      • <bdo id='CJXW5'></bdo><ul id='CJXW5'></ul>

                          <tbody id='CJXW5'></tbody>

                        1. <tfoot id='CJXW5'></tfoot>