Illegal NSTableViewDataSource

Hello:


I am getting the following error:


Illegal NSTableView data source: Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:


My tableView implementation is as follows:


import Cocoa
import CoreData
class RegistrationReportsViewController: NSViewController {
   
    override func viewDidLoad() {
        super.viewDidLoad()
        showRegisteredStudents()
        tableView.dataSource = self
        tableView.delegate = self
        tableView.reloadData()
    }
    private lazy var fetchedResultsController: NSFetchedResultsController = {
        let fetchRequest: NSFetchRequest = Registration.fetchRequest()
       let frc = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
        frc.delegate = (self as! NSFetchedResultsControllerDelegate)
        return frc
    }()
   
var items: [NSManagedObject] = []
   
var managedObjectContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
    let persistentContainer: NSPersistentContainer = {
           let container = NSPersistentContainer(name: "ScorcentMasterReview")
          
           container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error {
                   fatalError("Unresolved error \(error)")
               }           })
           return container
       }()

  

    @IBOutlet weak var tableView: NSTableView!

         var firstNameItem = "LAST"
         var middleNameItem = "MIDDLE"
         var lastNameItem = "FIRST"
 
func showRegisteredStudents() {
guard (NSApplication.shared.delegate as? AppDelegate) != nil  else {
               return
           }
        let managedContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
        let fetchRequest = NSFetchRequest(entityName: "Registration")
        fetchRequest.returnsObjectsAsFaults = false
           fetchRequest.sortDescriptors = [NSSortDescriptor(key: "lastName", ascending: true)]
    do {
          
       let items = try managedContext.fetch(fetchRequest) as! [NSManagedObject]
       print ("There are \(items.count) items")
    
        _ = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
             // Configure Fetched Results Controller
       print("Records are \(items)")
       self.tableView.reloadData()
       return()
    } catch {
    fatalError("Failed to fetch employees: \(error)")
    }
}
   
}
    extension RegistrationReportsViewController: NSTableViewDataSource{
    func numberOfRowsInTableView(tableView: NSTableView) -> Int {
    let numberOfRows:Int = items.count
        return numberOfRows
        }
    }
   
   
  //NSTableViewDelegate
extension RegistrationReportsViewController: NSTableViewDelegate{
    func configureCell(cell: NSTableCellView, row: Int, column: Int){

    let registration = fetchedResultsController.fetchedObjects! [row]
             switch column {
             case 0:
                cell.textField?.stringValue = registration.lastName ?? ""
             case 1:
                cell.textField?.stringValue = registration.firstName ?? ""
             case 2:
                cell.textField?.stringValue = registration.middleName ?? ""
             default:
                 break
             }
        
  func tableView(tableView: NSTableView!, objectValueForTableColumn tableColumn: NSTableColumn!, row: Int) -> AnyObject!{
    _ = fetchedResultsController.fetchedObjects! [row]
        let cell = tableView.makeView(withIdentifier: (tableColumn!.identifier), owner: self) as? NSTableCellView
        let column = tableView.tableColumns.firstIndex(of: tableColumn!)!
//       cell?.textField?.stringValue = registration[(tableColumn?.identifier.rawValue)!]!
    configureCell(cell: cell!, row: row, column: column)
            return cell
       
   }

}

I would appreciate any help that points me in the right direction. Thanks.

Answered by Claude31 in 401877022

It is normal delegate is not called when 0 row. But as soon as at least 1, should be called.


Your code is wrong:

extension RegistrationReportsViewController: NSTableViewDelegate{
    func configureCell(cell: NSTableCellView, row: Int, column: Int){
    let registration = fetchedResultsController.fetchedObjects! [row]
        print ("Start NSTableView Delegate")
             switch column {
             case 0:
                cell.textField?.stringValue = registration.lastName ?? ""
             case 1:
                cell.textField?.stringValue = registration.firstName ?? ""
             case 2:
                cell.textField?.stringValue = registration.middleName ?? ""
             default:
                 break
             }

        func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView?{
         let cell = tableView.makeView(withIdentifier: (tableColumn!.identifier), owner: self) as? NSTableCellView
         let column = tableView.tableColumns.firstIndex(of: tableColumn!)!
         configureCell(cell: cell!, row: row, column: column)
         return cell
               }
          }
}


Look, viewFor is defined inside configureCell.

So it is not visible as a delegate func.


Correct code is:

extension RegistrationReportsViewController: NSTableViewDelegate {

    func configureCell(cell: NSTableCellView, row: Int, column: Int) {

        let registration = fetchedResultsController.fetchedObjects! [row]
        print ("Start NSTableView Delegate")
        switch column {
             case 0:
                cell.textField?.stringValue = registration.lastName ?? ""
             case 1:
                cell.textField?.stringValue = registration.firstName ?? ""
             case 2:
                cell.textField?.stringValue = registration.middleName ?? ""
             default:
                 break
        }
    }

    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView?{

        let cell = tableView.makeView(withIdentifier: (tableColumn!.identifier), owner: self) as? NSTableCellView
        let column = tableView.tableColumns.firstIndex(of: tableColumn!)!
        configureCell(cell: cell!, row: row, column: column)
        return cell
     }

}


Note: a clear writing, with correct identation, does help to see it immediately.

Signature of

func tableView(tableView: NSTableView!, objectValueForTableColumn tableColumn: NSTableColumn!, row: Int) -> AnyObject!{

is wrong. Should be:

func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any?


Idem for number of rows.

Correct signature is

func numberOfRows(in tableView: NSTableView) -> Int



I also got a few warnings:

Line 45

let fetchRequest = NSFetchRequest(entityName: "Registration")

AppDelegate.swift:227:78: Value of type 'AppDelegate' has no member 'persistentContainer'

Proposed to change:

let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Registration")


Line 44

let managedContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

AppDelegate.swift:204:80: Value of type 'AppDelegate' has no member 'persistentContainer'

Maybe you have not posted the code where this is initialized ?


Don't you miss a closing } at the end of extension ?

Hello Claude:


With the suggested changes, the illegal datasource error was resolved, however, still, no data shows up in the tableView.

You probably have nothing in items.


Check with:

extension RegistrationReportsViewController: NSTableViewDataSource{

    func numberOfRowsInTableView(tableView: NSTableView) -> Int {
         let numberOfRows:Int = items.count
         print("dataSource rows:", numberOfRows)
         return numberOfRows
    }
}

Cause of problem:

Line 19: you declare an items var as empty

var items: [NSManagedObject] = []


line 50, you read items in a local var:

let items = try managedContext.fetch(fetchRequest) as! [NSManagedObject]

But you never set items of line 19.


Change as:

    do {
        
       let readItems = try managedContext.fetch(fetchRequest) as! [NSManagedObject]
       print ("There are \(readItems.count) items")
  
        _ = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
             // Configure Fetched Results Controller
       print("Records are \(readItems)")
       items = readItems          // NOW items is filled
       self.tableView.reloadData()
       return()
    } catch {
         fatalError("Failed to fetch employees: \(error)")
    }

Note: I did not check if

_ = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)

is correct. We'll see once you have made the changes above.


Note: it is a bit dangerous to use the same name for a local var as a more global var (items).

At the end, you don't know immediately which you are using (always the most local, but not immediate to detect when reading code).

An exception is to unwrap:

var myVar: Int? = 0
if var myVar = myVar {
}

Here you declare a new myVar locally, but there is no risk of confusion, because in fact you do speak of the same.

Hello Claude31:


I am getting a crash on:


self.tableView.reloadData()


Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

What have you changed that causes the crash ?


Where exactly did you get the crash (show the backtrace)


If you implemented the changes, what are the prints in console ?


I have not checked your implementation of fetch.

May have a look here:

h ttps://cocoacasts.com/populate-a-table-view-with-nsfetchedresultscontroller-and-swift-3

I submitted the full code:


The crash is on line 62


import Cocoa
import CoreData
class RegistrationReportsViewController: NSViewController {
   
    required init?(coder aDecoder: NSCoder) {
        self.items = []
        super.init(coder: aDecoder)
       
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        showRegisteredStudents()
        tableView.dataSource = self
        tableView.delegate = self
        tableView.reloadData()
    }
    private lazy var fetchedResultsController: NSFetchedResultsController = {
        let fetchRequest: NSFetchRequest = Registration.fetchRequest()
       let frc = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
        frc.delegate = (self as! NSFetchedResultsControllerDelegate)
        return frc
    }()
   
var items: [NSManagedObject]
   
var managedObjectContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
    let persistentContainer: NSPersistentContainer = {
           let container = NSPersistentContainer(name: "ScorcentMasterReview")
          
           container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error {
                   fatalError("Unresolved error \(error)")
               }           })
           return container
       }()

  

    @IBOutlet weak var tableView: NSTableView!

         var firstNameItem = "LAST"
         var middleNameItem = "MIDDLE"
         var lastNameItem = "FIRST"
 
func showRegisteredStudents() {
guard (NSApplication.shared.delegate as? AppDelegate) != nil  else {
               return
           }
        let managedContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
        let fetchRequest = NSFetchRequest(entityName: "Registration")
        fetchRequest.returnsObjectsAsFaults = false
           fetchRequest.sortDescriptors = [NSSortDescriptor(key: "lastName", ascending: true)]
    do {
           
      let readItems = try managedContext.fetch(fetchRequest) as! [NSManagedObject]
            print ("There are \(readItems.count) items")
        
             _ = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
                  // Configure Fetched Results Controller
            print("Records are \(readItems)")
            items = readItems          // NOW items is filled
            self.tableView.reloadData()
            return()
      } catch {
           fatalError("Failed to fetch employees: \(error)")
      }
}
   
}
extension RegistrationReportsViewController: NSTableViewDataSource{
    func numberOfRows(in tableView: NSTableView) -> Int {
    let numberOfRows:Int = items.count
        print("dataSource rows:", numberOfRows)
        return numberOfRows
        }
    }
   
   
  //NSTableViewDelegate
extension RegistrationReportsViewController: NSTableViewDelegate{
    func configureCell(cell: NSTableCellView, row: Int, column: Int){

    let registration = fetchedResultsController.fetchedObjects! [row]
             switch column {
             case 0:
                cell.textField?.stringValue = registration.lastName ?? ""
             case 1:
                cell.textField?.stringValue = registration.firstName ?? ""
             case 2:
                cell.textField?.stringValue = registration.middleName ?? ""
             default:
                 break
             }
         func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
    _ = fetchedResultsController.fetchedObjects! [row]
        let cell = tableView.makeView(withIdentifier: (tableColumn!.identifier), owner: self) as? NSTableCellView
        let column = tableView.tableColumns.firstIndex(of: tableColumn!)!
        configureCell(cell: cell!, row: row, column: column)
            return cell
       
   }

}

}

Yes, but what is the backtrace of the error ?


What are the results of the print statements ?


It seems that

func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {


is declared inside

func configureCell(cell: NSTableCellView, row: Int, column: Int){


which is not normal

Probably miss a closing curly brace line 94.

func showRegisteredStudents() {
guard (NSApplication.shared.delegate as? AppDelegate) != nil  else {
               return
           }
        let managedContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
        let fetchRequest = NSFetchRequest(entityName: "Registration")
        fetchRequest.returnsObjectsAsFaults = false
           fetchRequest.sortDescriptors = [NSSortDescriptor(key: "lastName", ascending: true)]
    do {
           
      let readItems = try managedContext.fetch(fetchRequest) as! [NSManagedObject]
            print ("There are \(readItems.count) items")
        
             _ = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
                  // Configure Fetched Results Controller
            print("Records are \(readItems)")
            items = readItems          // NOW items is filled
            self.tableView.reloadData()
            return()
      } catch {
           fatalError("Failed to fetch employees: \(error)")
      }
}
   
}
extension RegistrationReportsViewController: NSTableViewDataSource{
    func numberOfRows(in tableView: NSTableView) -> Int {
    let numberOfRows:Int = items.count
        print("dataSource rows:", numberOfRows)
        return numberOfRows
        }
    }
   
   
  //NSTableViewDelegate
extension RegistrationReportsViewController: NSTableViewDelegate{
    func configureCell(cell: NSTableCellView, row: Int, column: Int){

    let registration = fetchedResultsController.fetchedObjects! [row]
             switch column {
             case 0:
                cell.textField?.stringValue = registration.lastName ?? ""
             case 1:
                cell.textField?.stringValue = registration.firstName ?? ""
             case 2:
                cell.textField?.stringValue = registration.middleName ?? ""
             default:
                 break
             }


}
         func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
     _ = fetchedResultsController.fetchedObjects! [row]
         let cell = tableView.makeView(withIdentifier: (tableColumn!.identifier), owner: self) as? NSTableCellView
         let column = tableView.tableColumns.firstIndex(of: tableColumn!)!
         configureCell(cell: cell!, row: row, column: column)
             return cell
        
    }

}

The trace logs is as follows:


CoreData: annotation: fetch using NSSQLiteStatement <0x600002132260> on entity 'Registration' with sql text 'SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZFIRSTNAME, t0.ZLASTNAME, t0.ZMIDDLENAME FROM ZREGISTRATION t0 ORDER BY t0.

"<Registration: 0x60000212e210> (entity: Registration; id: 0xead49ac53dfb5197 <x-coredata://7F2F361B)

CoreData: annotation: total fetch execution time: 0.0010s for 1 rows.

CoreData: details: SQLite: EXPLAIN QUERY PLAN SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZFIRSTNAME, t0.ZLASTNAME, t0.ZMIDDLENAME FROM ZREGISTRATION t0 ORDER BY t0.ZLASTNAME

3 0 0 SCAN TABLE ZREGISTRATION AS t0

14 0 0 USE TEMP B-TREE FOR ORDER BY

There are 1 items

Records are [<Registration: 0x60000212e210> (entity: Registration; id: 0xead49ac53dfb5197 <x-coredata://7F2F361B-2C31-4CC0-9E6D-660E8277D9B9/Registration/p3>; data: {

firstName = John;

lastName = Doe;

middleName = Jan;

})]

Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file /Users/wlionelwilliams/Desktop/SMRP/ScorcentMasterReview/ScorcentMasterReview/RegistrationReportsViewController.swift, line 62

2020-01-09 15:05:35.093504-0500 ScorcentMasterReview[62567:30216759] Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file /Users/wlionelwilliams/Desktop/SMRP/ScorcentMasterReview/ScorcentMasterReview/RegistrationReportsViewController.swift, line 62

(lldb)

Surprised that this print does not show:


    func numberOfRows(in tableView: NSTableView) -> Int { 
        let numberOfRows:Int = items.count 
        print("dataSource rows:", numberOfRows) 
        return numberOfRows 
        } 
    }


You get 1 item. Is it what you expect ?


Can you identify precisely where this is ?

/Users/wlionelwilliams/Desktop/SMRP/ScorcentMasterReview/ScorcentMasterReview/RegistrationReportsViewController.swift, line 62

Hello Claude:


func showRegisteredStudents() {
guard (NSApplication.shared.delegate as? AppDelegate) != nil  else {
               return
           }
        let managedContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
        let fetchRequest = NSFetchRequest(entityName: "Registration")
        fetchRequest.returnsObjectsAsFaults = false
           fetchRequest.sortDescriptors = [NSSortDescriptor(key: "lastName", ascending: true)]
    do {
           
      let readItems = try managedContext.fetch(fetchRequest) as! [NSManagedObject]
            print ("There are \(readItems.count) items")
        
             _ = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
                  // Configure Fetched Results Controller
            print("Records are \(readItems)")
            items = readItems
        print("There are \(items.count) items")// NOW items is filled
            self.tableView.reloadData()
            return()
           fatalError("Failed to fetch employees: \(error)")
      }
  
    }

     }
extension RegistrationReportsViewController: NSTableViewDataSource,NSTableViewDelegate{
    
    // DataSource
    
    func numberOfRows(in tableView: NSTableView) -> Int {
    let numberOfRows:Int = items.count
        print("dataSource rows:", numberOfRows)
        return numberOfRows
        }
        // Delegate
    
    func configureCell(cell: NSTableCellView, row: Int, column: Int){

    let registration = fetchedResultsController.fetchedObjects! [row]
             switch column {
             case 0:
                cell.textField?.stringValue = registration.lastName ?? ""
             case 1:
                cell.textField?.stringValue = registration.firstName ?? ""
             case 2:
                cell.textField?.stringValue = registration.middleName ?? ""
             default:
                 break
             }
        
        }
         func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
     _ = fetchedResultsController.fetchedObjects! [row]
         let cell = tableView.makeView(withIdentifier: (tableColumn!.identifier), owner: self) as? NSTableCellView
         let column = tableView.tableColumns.firstIndex(of: tableColumn!)!
         configureCell(cell: cell!, row: row, column: column)
             return cell
         
 }
  

}


I expect only one item.


That test is on line 18 above.


       print("There are \(items.count) items")// NOW items is filled


The crash occurs on line 19.


    print("There are \(items.count) item //Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file


No of the tests in the extensions are reached. Can't see why, even when I separate the DataSource from the Delegate.

Found it.


You call


showRegisteredStudents()


bfore setting the delegate of tableView.


Change as:

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.dataSource = self     // Do this FIRST
        tableView.delegate = self

        showRegisteredStudents()
        tableView.reloadData()     //  not needed, done in showRegisteredStudents
    }

Hello Claude:


See if the code you checked is the same as this because when I run it with changes I get the crash at line 12


import Cocoa
import CoreData
class RegistrationReportsViewController: NSViewController {
requiredinit?(coder aDecoder: NSCoder) {
self.items = []
super.init(coder: aDecoder)
    }
overridefunc viewDidLoad() {
super.viewDidLoad()
           tableView.dataSource = self     // Do this FIRST
           tableView.delegate = self
           showRegisteredStudents()
               //  not needed, done in showRegisteredStudents
       }
privatelazyvar fetchedResultsController: NSFetchedResultsController = {
let fetchRequest: NSFetchRequest = Registration.fetchRequest()
let frc = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
        frc.delegate = (selfas! NSFetchedResultsControllerDelegate)
return frc
    }()
var items: [NSManagedObject]
var managedObjectContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "ScorcentMasterReview")
           container.loadPersistentStores(completionHandler: { (storeDescription, error) in
iflet error = error {
                   fatalError("Unresolved error \(error)")
               }           })
return container
       }()


@IBOutletweakvar tableView: NSTableView!

var firstNameItem = "LAST"
var middleNameItem = "MIDDLE"
var lastNameItem = "FIRST"
func showRegisteredStudents() {
guard (NSApplication.shared.delegate as? AppDelegate) != nilelse {
return
           }
let managedContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let fetchRequest = NSFetchRequest(entityName: "Registration")
        fetchRequest.returnsObjectsAsFaults = false
           fetchRequest.sortDescriptors = [NSSortDescriptor(key: "lastName", ascending: true)]
do {
let readItems = try managedContext.fetch(fetchRequest) as! [NSManagedObject]
            print ("There are \(readItems.count) items")
_ = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
                  // Configure Fetched Results Controller
            print("Records are \(readItems)")
            items = readItems
        print("There are \(items.count) items")// NOW items is filled
        tableView.reloadData()
return()
      } catch {
           fatalError("Failed to fetch employees: \(error)")
      }
    }
    }
extension RegistrationReportsViewController: NSTableViewDataSource{
    // DataSource
func numberOfRows(in tableView: NSTableView) -> Int {
let numberOfRows:Int = items.count
        print("dataSource rows:", numberOfRows)
return numberOfRows
        }
}
        // Delegate
extension RegistrationReportsViewController: NSTableViewDelegate{
func configureCell(cell: NSTableCellView, row: Int, column: Int){

let registration = fetchedResultsController.fetchedObjects! [row]
switch column {
case 0:
                cell.textField?.stringValue = registration.lastName ?? ""
case 1:
                cell.textField?.stringValue = registration.firstName ?? ""
case 2:
                cell.textField?.stringValue = registration.middleName ?? ""
default:
break
             }
        }
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
_ = fetchedResultsController.fetchedObjects! [row]
let cell = tableView.makeView(withIdentifier: (tableColumn!.identifier), owner: self) as? NSTableCellView
let column = tableView.tableColumns.firstIndex(of: tableColumn!)!
         configureCell(cell: cell!, row: row, column: column)
return cell
}
}


Did you check that tableView is properly connected to its IBOutlet ?

=> Disconnect, reconnetc and do a clean build folder


When you crash, do you get some log printed before ?


Try and keep reloadData on line 13, but I really think it is superfluous (if not done in showRegisteredStudents, there should be a fatal crash).


Question: why did you use

tableView(_:objectValueFor:row:)

and not

func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView?

or

func tableView(_ tableView: NSTableView, dataCellFor tableColumn: NSTableColumn?, row: Int) -> NSCell?

Does your code compile ?


I get errors (in addition to all the missing spaces everywhere):


line 15 : Generic parameter 'ResultType' could not be inferred

Need something like:

private lazy var fetchedResultsController: NSFetchedResultsController<ResultType> = {


line 24: Value of type 'AppDelegate' has no member 'persistentContainer'

line 42: Generic parameter 'ResultType' could not be inferred

Need something like:

let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Registration")



So the code you post is not the one you use.

Illegal NSTableViewDataSource
 
 
Q