任何帮助表示赞赏。Swift 3 - NSFetchRequest不同的结果
Xcode的自动更新,以8 ...我瞄准IOS 9.3
让所有跨转换的代码,但有一件事现在已经打破,我曾尝试过各种建议,类似的问题!我的提取请求,是以前的工作现在正在打破。
我的目标是获得一个清晰的列表。
let results = try context.fetch(fetchRequest)
随着控制台,所述的错误:在该行上的应用程序崩溃
Could not cast value of type 'NSKnownKeysDictionary1' (0x10fd29328) to 'MyApp.BodyType' (0x10eebc820).
下面是函数
func getBodyTypes() {
let context = ad.managedObjectContext
let fetchRequest = NSFetchRequest<BodyType>(entityName: "BodyType")
fetchRequest.propertiesToFetch = ["name"]
fetchRequest.returnsDistinctResults = true
fetchRequest.resultType = NSFetchRequestResultType.dictionaryResultType
do {
let results = try context.fetch(fetchRequest)
for r in results {
bodyTypes.append(r.value(forKey: "name") as! String)
}
} catch let err as NSError {
print(err.debugDescription)
}
}
如果下面的线被隐藏它不”吨休息,但后来我没有得到我想要的!
fetchRequest.resultType = NSFetchRequestResultType.dictionaryResultType
我明白我可以使用所有的结果(4300)和循环通过他们的绷带固定的,但是这并不觉得解决这个问题的正确方法,尤其是因为它之前的工作!
同样的问题。你解决了吗? –
同样在这里:/任何新闻?我也通过遍历非明显的结果并忽略重复来临时解决它。 – datayeah
同样的问题......我将要做的是@datayeah暂时正在做的事情,但除此之外无法从SQL方面找到任何解决方案。 –