我打开了一个项目,并Xcode
要求我将源代码更新为Swift 3
。单击保存后,我得到了预期的错误。建立时发生错误fetchRequest
。(第8行中的错误消息错误)
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let appDelegate = UIApplication.shared().delegate as! AppDelegate
let managedContext = appDelegate.managedObjectContext!
let fetchRequest = NSFetchRequest(entityName:"Sessions") //<- Error error message: generic parameter 'ResultType' could not be inferred
do {
sessions = try managedContext.fetch(fetchRequest) as! [Sessions]
} catch let error as NSError {
print("Could not fetch \(error), \(error.userInfo)")
}
print("fetched")
self.tableView.reloadData()
}
}
我自己也为此找到了解决方案。我刚从
let fetchRequest = NSFetchRequest(entityName:"Sessions")
到
let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName:"Sessions")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句