无法从CoreData访问提取的对象

时间:2018-04-24 18:31:02

标签: ios swift core-data

我正在尝试从NSFetchedResultsController访问提取的对象,但每次我尝试访问时,都会显示错误

  

***因未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'在-performFetch之前'无法访问已获取的对象:'

以下是访问已获取对象的代码

do {
    try self.fetchedResultsController.performFetch()
} catch {
    print("An error occured when fetching results")
}

//  First layout if needed
self.tableView.reloadData()

if let orderUUID = notification.object as? String,
    let orders = self.fetchedResultsController.fetchedObjects as? [CustomObject],
    let thisOrder = orders.filter({ $0.order!.uuid! == orderUUID }).first,
    let indexPath = self.fetchedResultsController.indexPath(forObject: thisOrder) {
        Log.verbose?.message("Order Detail opening after notification \(orderUUID) at Index \(indexPath)")
}

0 个答案:

没有答案