[Core Data] Building Blocks
[Core Data] Building Blocks
bromp2022년 12월 15일 19:33 0 0 6 0

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
댓글 0개
서버로 재접속을 시도하고 있습니다. 잠시만 기다려 주세요.