@IBOutlet var folderPathAC: NSArrayController!
static var appDelegate = NSApplication.shared.delegate as! AppDelegate
static var context = appDelegate.persistentContainer.viewContext
override func viewDidLoad() {
super.viewDidLoad()
updateUITable()
// Do any additional setup after loading the view.
}
func updateUITable(){
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "FolderPaths")
//request.predicate = NSPredicate(format: "age = %@", "12")
request.returnsObjectsAsFaults = false
do {
let result = try ViewController.context.fetch(request)
for data in result as! [NSManagedObject] {
let name = data.value(forKey: "folderName") as! String
let path = data.value(forKey: "folderPath") as! String
let folder = FolderPath(path: path, name: name)
self.folderPathAC.addObject(folder)
}
} catch {
print("Failed")
}
}
I am using the above code to populate a table view at the time of the app start in a macOS app. However, I am getting the following exception in the AppDelegate class at the runtime.
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
I am new to Mac development.