title: How to set a custom store URL for NSPersistentContainer
body: <p>How can I set a custom store.sqlite URL to NSPersistentContainer?</p>
  
  <p>I have found an ugly way, subclassing NSPersistentContainer:</p>
  
  <pre><code>final public class PersistentContainer: NSPersistentContainer {
  private static var customUrl: URL?
  
  public init(name: String, managedObjectModel model: NSManagedObjectModel, customStoreDirectory baseUrl:URL?) {
      super.init(name: name, managedObjectModel: model)
      PersistentContainer.customUrl = baseUrl
  }
  
  override public class func defaultDirectoryURL() -&gt; URL {
      return (customUrl != nil) ? customUrl! : super.defaultDirectoryURL()
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Is there a nice way?</p>
  
  <p>Background: I need to save to an App Groups shared directory.</p>