Here are the steps to use Core Data
in Swift
:
Core Data
..xcdatamodeld
file and create a new entity with its attributes.NSManagedObject
subclasses for your entities by going to Editor > Create NSManagedObject Subclass.NSPersistentContainer
instance in your AppDelegate.loadPersistentStores()
method on the persistent container.viewContext
property on the persistent container.Here's an example of adding an entry to a Core Data
entity:
main.swift482 chars16 lines
gistlibby LogSnag