NSPersistentContainer


Model

.xcdatamodeld 파일에서 생성

import Foundation
import CoreData

@objc(Movie)
public class Movie: NSManagedObject {
	
}

Managed Object Context

  • Create, load and manipulate managed objects
  • A Single Application can have multiple managed object contexts
  • Responsible for executing queries on the store

NSPersistentStoreCoordinator

  • Requires managed object context to initialize
  • Allows to setup underlying storage (SQLite is default)
  • Responsible for executing queries on the store
// prints the path of the documents directory
let dirPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
print(dirPaths[0])

Storage

  • XML (not available in iOS)
  • Binary
  • SQLite
  • In-Memory