Reputation: 9072
Here is my code I'm running and I used console messages to pinpoint that it crashes right when the let frc command is running. Interestingly enough I have another project where I'm using more or less the same code and it works but I can't tell what I'm doing any differently. Was hoping maybe someone here had some possible insight into this?
//Create fetchedResultsController to handle Inventory Core Data Operations
lazy var fetchedResultsController: NSFetchedResultsController<Workorders> = {
return self.setFetchedResultsController()
}()
func setFetchedResultsController() -> NSFetchedResultsController<Workorders>{
print("setFetchedResultsController()")
let context = gm_getContext()
let workordersFetchRequest: NSFetchRequest<Workorders> = Workorders.fetchRequest()
print("set fetch request")
let frc = NSFetchedResultsController <Workorders>(
fetchRequest: workordersFetchRequest,
managedObjectContext: context,
sectionNameKeyPath: nil,
cacheName: nil)
print("set the frc")
frc.delegate = self
return frc
}
I've looked into the documentation for Apple and it says I can set sectionNameKeyPath to nil and cache to nil, so I'm not sure what I'm doing wrong.
Upvotes: 2
Views: 291
Reputation: 17354
From the apple documentation:
A fetch request. This must contain at least one sort descriptor to order the result
Upvotes: 3