0
我在創建我的NSFetchedResultsController
時收到objc_exception_throw。我對iOS編程相對比較陌生,所以我仍然在調試iOS崩潰。NSFetchedResultsController在創建時崩潰,objc_exception_throw
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
lazy var parentContext: NSManagedObjectContext? = {
if let managedObjectContext = self.appDelegate.managedObjectContext {
return managedObjectContext
}
else {
return nil
}
}()
lazy var fetchedResultsController: NSFetchedResultsController = {
let request = NSFetchRequest()
let entity = NSEntityDescription.entityForName("GameDate", inManagedObjectContext: self.parentContext!)
request.entity = entity
let frc = NSFetchedResultsController(fetchRequest: request, managedObjectContext: self.parentContext!, sectionNameKeyPath: nil, cacheName: nil)
frc.delegate = self
return frc
}()
override func viewDidLoad() {
super.viewDidLoad()
performFetchFromDb()
setupTableView()
}
我收到這條線上的崩潰:
let frc = NSFetchedResultsController(fetchRequest: request, managedObjectContext: self.parentContext!, sectionNameKeyPath: nil, cacheName: nil)
這是否崩潰有些事情要與我的背景?
堆棧跟蹤和錯誤,我們不是魔術師:) – Schemetrical
@Schemetrical什麼?!你不是魔術師?!爲什麼我甚至在這裏呢!哈哈我真的明白了,我沒有在那裏放置一個排序描述符。我會盡我所能做出自己的答案。 –