0
我想在斯威夫特3實施fetchedresultsviewcontroller和控制器的委託屬性設置爲自當我遇到了以下錯誤:在斯威夫特實施fetchedresultsviewcontroller 3
無法指定類型的值「SomeRootViewController」鍵入 'NSFetchedResultsControllerDelegate?'
SomeRootViewController.swift
@available(iOS 10.0, *)
@objc class SomeRootViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var delegate: SomeRootViewControllerDelegate?
public var context: NSManagedObjectContext!
private let persistentContainer = NSPersistentContainer(name: "Accessory")
fileprivate lazy var fetchedResultsController: NSFetchedResultsController<Accessory> = {
// Create Fetch Request
let fetchRequest: NSFetchRequest<Accessory> = Accessory.fetchRequest() as! NSFetchRequest<Accessory>
// Configure Fetch Request
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "AccessoryAttributes.name", ascending: true)]
// Create Fetched Results Controller
let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
// Configure Fetched Results Controller
fetchedResultsController.delegate = self //<<-- this is where error occurs
return fetchedResultsController
}()
有人可以解釋這個問題給我,我怎麼能解決這個問題?
謝謝!非常正確! – Vee