我已经开始尝试使用酷睿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 useNSManagedobject
.- 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
likeClassName+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.