用swift创建CoreData项目时,操作CoreData Modal时,出现下面错误
CoreData: warning: Unable to load class named 'Book' for entity 'Book'. Class not found, using default NSManagedObject instead.
1. 在book.swift 中添加 @objc(Book)
2. 修改CoreData模板
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Core Data
/NSManagedObject subclass.xctemplate复制到~/Library/Developer/Xcode/Templates
下,如果没有Templates文件夹,创建文件夹Templates
修改___FILEBASENAME___.swift 文件,添加@objc(___FILEBASENAMEASIDENTIFIER___),如下
import Foundation import CoreData @objc(___FILEBASENAMEASIDENTIFIER___) class ___FILEBASENAMEASIDENTIFIER___: ___COREDATAMANAGEDOBJECTSUPERCLASS___ { ___COREDATAPROPERTYIMPLEMENTATIONS___ }
swift CoreData中CoreData: warning: Unable to load class named问题
原文地址:http://blog.csdn.net/yanglishuan/article/details/40619601