title: How to include NSPersistentContainer in AppDelegate
body: <p>I'm receiving an error:</p>
  
  <blockquote>
    <p>AppDelegate has no member persistentContainer</p>
  </blockquote>
  
  <pre><code>import UIKit
  import CoreData
  
  class ViewController: UIViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
          let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
          let context = appDelegate.persistentContainer.viewContext // Error: value of type 'AppDelegate' has no member 'persistentContainer'
      }
  
  }
  </code></pre>
  
  <p>In AppDelegate.swift file, NSPersistentStoreCoordinator is defined as default.</p>
  
  <pre><code>lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
      let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
      let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("SingleViewCoreData.sqlite")
      var failureReason = "There was an error creating or loading the application's saved data."
      do {
          try coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil)
      }
      catch {
          var dict = [String: AnyObject]()
          dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
          dict[NSLocalizedFailureReasonErrorKey] = failureReason
          dict[NSUnderlyingErrorKey] = error as NSError
          let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
          NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
          abort()
      }
      return coordinator
  }()
  </code></pre>