title: CoreData: What's the difference between performBackgroundTask and newBackgroundContext()?
body: <p>What's the difference between these two approaches?</p>
  
  <pre><code>container.performBackgroundTask { (context) in 
      // ... do some task on the context
  
      // save the context
      do {
          try context.save()
      } catch {
          // handle error
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>let context = persistentContainer.newBackgroundContext()
  context.perform {
      // ... do some task on the context
  
      // save the context
      do {
          try context.save()
      } catch {
          // handle error
      }
  }
  </code></pre>
  
  <p>When to use the first and when to use the second approach?</p>