[Core Data] Building Blocks

brick·2022년 12월 15일
0

Core Data

목록 보기
2/2
post-thumbnail

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개의 댓글