【发布时间】:2016-01-11 13:24:26
【问题描述】:
我在 Swift 2.1 和 Xcode 7.2 中使用 Core 数据 此代码给了我一个找不到实体名称的错误。这是因为 [Company] 不起作用。我有一个具有此名称的实体。
let fetchRequest = NSFetchRequest(entityName: "Company")
do {
var result = try self.moc.executeFetchRequest(fetchRequest) as! [Company]
if (result.count > 0){
companyName?.stringValue = result[0].valueForKeyPath("name") as! String
// success ...
}
else{
}
} catch let error as NSError {
// failure
print("Fetch failed: \(error.localizedDescription)")
}
【问题讨论】:
标签: swift entity nsfetchrequest