Codegen: Class Definition
Class Definition automatically creates the NSManagedObject subclass behind the scene, including the attributes information.
Codegen: Category/Extension
Category/Extension allow flexibility of using the class file to handle custom function, whereas the properties file is still created and loaded behind the scene.
在使用这种模式的情况下,添加类的自定义函数时,需要手工创建该类的(Movie)的 extension 文件 Movie+CoreDataClass.swift
,手动新建该类,如下截图所示。

如果忘记了 @objc(Movie)
会报错 An NSManagedObject of class 'Movie.Movie' must have a valid NSEntityDescription
。

分类:iOS