【发布时间】:2015-08-17 05:42:52
【问题描述】:
当我创建我的核心数据文件并将此代码添加到 done 方法以保存数据后,我收到了上述主题的错误找不到类。
它也显示错误
找不到类,使用默认的 NSManagedObject 代替
@IBAction func done()
{
let hudView = HudView.hudInView(navigationController!.view, animated: true)
hudView.text = "Tagged"
let location = NSEntityDescription.insertNewObjectForEntityForName("Location", inManagedObjectContext: managedObjectContext) as! Location
location.locationDescription = descriptionText
location.category = categoryName
location.latitude = coordinate.latitude
location.longitude = coordinate.longitude
location.date = date
location.placemark = placemark
var error: NSError?
if !managedObjectContext.save(&error)
{
println("Error: \(error)")
abort()
}
afterDelay(0.6) {self.dismissViewControllerAnimated(true, completion: nil)}
}
【问题讨论】:
-
你的项目目录中有 Location 类吗?
-
是的,但位置文件不是位置类
-
我的项目目录中的项目中也有位置类
-
是“类位置:NSManagedObject {”这样的吗?
-
是的,和你说的一样。
标签: ios iphone swift core-data