Core Data (CRUD)
Core data
- Have data constraints feature
- Operates on data, stored on disk
- Can drop table and edit data without loading them in memory
- Slow as compared to core data
- Operates on memory
- Data needs to be loaded from disk to memory to do any operations
- Fast in terms of record creation (saving may be time consuming)
- ViewContext
- NSManageObject
- NSEntity
- NSFetchRequest
- NSPredicates
- Relationships
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return nil
}
let context = appDelegate.persistentContainer.viewContext
ManagedObjectName(entity: Entity, insertInto: Context)
NSEntityDescription.entity(forEntityName: EntityName, in: Context)
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: EntityName)
fetchRequest.predicate = NSPredicate(format: "%K = %@", ColumnName, Value as CVarArg)
do {
let results = try Context.fetch(fetchRequest)
} catch let error as NSError {
print(error)
}
do {
try Context.save()
} catch let error as NSError {
print(error)
}
Core data
https://medium.com/@ankurvekariya/core-data-crud-with-swift-4-2-for-beginners-40efe4e7d1cc
https://medium.com/xcblog/core-data-with-swift-4-for-beginners-1fc067cca707
https://wojciechkulik.pl/ios/getting-started-with-core-data-using-swift-4
https://medium.com/@aliakhtar_16369/mastering-in-coredata-part-5-relationship-between-entities-in-core-data-b8fea1b50efb. (Relationship)
https://developer.apple.com/videos/play/wwdc2019/230
Core data with Cloudkit
https://developer.apple.com/videos/play/wwdc2019/202
https://developer.apple.com/library/archive/qa/qa1952/_index.html
Comments
Post a Comment