0
我已經在屏幕上分段控制。 1個分段項目用於廣告(廣告表格),第二個分段項目用於訂單(訂單表格)。 當用戶選擇所分割的項每一次,我重新NSFetchResultController的新實例讀取請求到另一個數據表(但UI我總是隻有一個的UITableView self.tableViewMain
):NSFetchedResultsController performFetch不起作用
let entityName = screen == ProfileScreen.Ads ? kDB_entity_DBAd : kDB_entity_DBOrder
let entityDescription = NSEntityDescription.entityForName(entityName, inManagedObjectContext: (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext)
let fetchRequest = NSFetchRequest()
fetchRequest.entity = entityDescription
self.fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: (UIApplication.sharedApplication().delegate! as! AppDelegate).managedObjectContext, sectionNameKeyPath: nil, cacheName: nil)
do {
try fetchedResultsController!.performFetch()
} catch {
print("An error occurred in fetchresultcontroller")
}
但是第一次重新加載數據正確,但第二次fetchresultcontroller甚至不重新加載表(不調用numberOfRowsInSection and cellForRowAtIndexPath
)。因此,當我調用fetchedResultsController!.performFetch()