核心数据 – 使用swift 3和Xcode 8 beta对NSManagedObject进行子类化

我已经开始尝试使用酷睿3和Xcode 8测试版的核心数据。当我尝试从核心数据模型生成NSManagedobject子类并在编辑器菜单中创建NSManagedobject子类…选项时,Xcode 8 beta生成三个文件,其中之一是_COREDATA_DATAMODELNAME_ CoreDataModel.swift,其内容如下:
import Foundation
import CoreData

___COREDATA_DATAMODEL_MANAGEdobJECTCLASSES_IMPLEMENTATIONS___

此外,此文件内容显示两个警告:

Expressions are not allowed at the top level.
Use of unresolved identifier '___COREDATA_DATAMODEL_MANAGEdobJECTCLASSES_IMPLEMENTATIONS___'

有没有人面临同样的问题?这个新文件的意思是什么?

谢谢

这可能是与新的自动子类生成(beta)冲突,可以在数据模型文件的实体检查器中进行控制。

documentation (What’s New In Core Data)

Xcode automatic subclass generation

Xcode Now supports automatic generation of NSManagedobject subclasses
in the modeling tool. In the entity inspector:

  • Manual/None is the default,and prevIoUs behavior; in this case you
    should implement your own subclass or use NSManagedobject.
  • Category/Extension generates a class extension in a file named like
    ClassName+CoreDataGeneratedProperties. You need to declare/implement
    the main class (if in Obj-C,via a header the extension can import
    named ClassName.h). –
  • Class DeFinition generates subclass files named
    like ClassName+CoreDataClass as well as the files generated for
    Category/Extension.

The generated files are placed in DerivedData and rebuilt on the first build after the model is saved. They are also indexed by Xcode,so command-clicking on references and fast-opening by filename works.

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...