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