title: UI API called on a background thread error
body: <p>I have a function that gets the context for storing to Core Data. I have it for a few view controllers, however I am getting an error.</p>
  
  <pre><code>private class func getContext() -&gt; NSManagedObjectContext {
      let appDelegate = UIApplication.shared.delegate as! AppDelegate       
      return appDelegate.weatherPersistentContainer.viewContext
  }
  </code></pre>
  
  <p>However I get an error about accessing UI API being called from a background thread.</p>