title: An instance of NSFetchedResultsController requires a non-nil fetchRequest and managedObjectContext'
body: <p>Other people have asked a similar question, but the answers given did not help me. I am trying to create a table view with core data and I keep getting an error message that my fetchRequest and/or managedObjectContext are nil</p>
  
  <pre><code>class CustomTableViewController: UITableViewController, 
  NSFetchedResultsControllerDelegate {
  
  var coreDataContext = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
  
  
  @available(iOS 10.0, *)
  fileprivate lazy var fetchedResultsController: NSFetchedResultsController&lt;Movie&gt; = {
      // Initiate the query
      let fetchRequest: NSFetchRequest&lt;Movie&gt; = Movie.fetchRequest() as! NSFetchRequest&lt;Movie&gt;
  
      // Sort the data
      fetchRequest.sortDescriptors = [NSSortDescriptor(key:"title", ascending: true)]
  
    NSLog("Request: %@, Context: %@", fetchRequest, self.coreDataContext);        
    let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.coreDataContext, sectionNameKeyPath: nil, cacheName: nil)
  
      fetchedResultsController.delegate = self
      return fetchedResultsController
  }()
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      navigationController?.setToolbarHidden(false, animated: false)
  
      do {
          // when view loads, run the fetch (query)
          if #available(iOS 10.0, *) {
              try self.fetchedResultsController.performFetch()
          } else {
              // Fallback on earlier versions
          }
      } catch {
          let fetchError = error as NSError
          print("Unable to Perform Fetch Request")
          print("\(fetchError)")
      }
      }
  </code></pre>
  
  <p>Does anyone have any ideas what's wrong? Also, not sure if it matters, but my project is a mix of both Objective-C and Swift </p>
  
  <p>Also, the <code>NSLog("Request: %@, Context: %@", fetchRequest, self.coreDataContext)</code> from my above code prints out:</p>
  
  <pre><code>Request: (null), Context: &lt;NSManagedObjectContext: 0x1701db4e0&gt;
  </code></pre>
  
  <p>I have an entity called Movie in my xcdatamodeld with three String attributes. I also created a class for Movie like this in its own Movie.swift file:</p>
  
  <pre><code>import UIKit
  import CoreData
  
  class Movie: NSManagedObject {
  
  }
  </code></pre>