0
我想基于属性名称获取记录。核心数据获取请求错误
我也试图寻找类似的问题,但我不能够找到解决办法,所以我张贴问题...
,但我得到的异常而获取:
[error] error: exception handling request: <NSSQLFetchRequestContext: 0x1c019a270> , keypath audio_1.m4a not found in entity <NSSQLEntity answer id=8> with userInfo of (null)
CoreData: error: exception handling request: <NSSQLFetchRequestContext: 0x1c019a270> , keypath audio_1.m4a not found in entity <NSSQLEntity answer id=8> with userInfo of (null)
2017-09-28 19:03:36.725060+0530 app[9684:891158] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath audio_1.m4a not found in entity <NSSQLEntity answer id=8>'
我的代码:
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: Entity)
if let predic = predicate_str{
let predicate = NSPredicate(format: predic)
fetchRequest.predicate=predicate
}
do {
let arr = try appsession.managedObjectContext.fetch(fetchRequest) //CRASHED
// success ...
} catch let error as NSError {
// failure
print("Fetch failed: \(error.localizedDescription)")
return(nil,error)
}
谢谢
什么是'predicate_str'?什么是“实体”? – jrturton
@jrturton,实体是“答案”&predicate_str =“imagePath LIKE [c] audio_1.m4a” – nirav