Error below is caused by the 'let managedObjectContext = getMainContext()
' line of code, whats causing this as I couldnt see why i wouldnt be able to use the function without issue
Use of instance member 'getMainContext' on type 'RoutineController'; did you mean to use a value of type 'RoutineController' instead?
fileprivate lazy var fetchedExercisesTodayController: NSFetchedResultsController<UserExercise> = {
let managedObjectContext = getMainContext()
let userExercise = UserExercise(context: managedObjectContext)
let fetchRequest: NSFetchRequest<UserExercise> = UserExercise.fetchRequest()
fetchRequest.predicate = NSPredicate(format: "(usersroutine == %@)", self.routineName)
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "id", ascending: true)] //this isnt really needed
let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil)
fetchedResultsController.delegate = self
return fetchedResultsController
}()
func getMainContext() -> NSManagedObjectContext {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
return appDelegate.persistentContainer.viewContext
}