-1
我得到一個編譯器錯誤,下面的代碼。 Scores
是動態生成的數據實體(Codegen - Class Defnition)。確切的錯誤是:NSFetchRequest參數錯誤
無法轉換值類型的 'NSFetchRequest <成績>' 預期參數類型 'NSFetchRequest <NSFetchRequestResult>'
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let request: NSFetchRequest<Scores> = Scores.fetchRequest()
do {
scores = try context.fetch(request)
} catch {
print("Error")
}
tableView.reloadData()
}
在context.fetch()
調用發生的錯誤。 Xcode中8.2.1
替換fetchrequest創建具有低於線 令請求:NSFetchRequest = Scores.fetchRequest() 這對類似問題的詳細引線。 https://stackoverflow.com/questions/37810967/how-to-apply-the-type-to-a-nsfetchrequest-instance –
pkallu
啊,我實際上閱讀並錯過了它。我的語法是針對自定義實體類的,這是我開始使用的,但後來更改爲動態Codegen。 @pkallu建議並將結果轉換爲獲取行上的實體對其進行修復。謝謝。 –