a coredata journey
DESCRIPTION
A CoreData Journey, presentation given at CodeCamp on 10 Mai 2014.TRANSCRIPT
A Core Data Journey
Who Am I?
• Alex Terente
• Mainly iOS developer
• Consultant and working @ TAGonSoft
What is Core Data?
“The Core Data framework provides generalized and automated solutions to common tasks associated with object life-cycle and object graph management, including persistence.”
What is Core Data?
• Allows definition of Managed Objects
• Functionality to create, update, delete, query
• Multiple back-end storage options
Storage Options• Binary
• In-memory
• XML
• Not available on the iPhone
• SQLite
• Only option that does not require the entire store to reside in memory
What is not Core Data
• Core Data is not a relational database or a relational database management system
• Core Data is not a silver bullet.
Core Data vs. SQLiteSQLite Core Data
Bulk/Set Operations
Yes No
Automatic object
populationNo Yes
Custom SQL Yes No
Select only certain fields
Yes No
Automated Migrations
No Yes
Less Complex Code
No Yes
Interface to Core Data
NSPersistentStore
NSPersistentStoreCoordinator
NSManagedObjectContext
NSPersistentStoreCoordinator
NSManagedObjectModel
Model Demo
NSManagedObjectContext
Inserting an Object
Querying for Objects
Deleting an Object
Updating an Object
• Same as insert
• Make changes followed by ManagedObjectContext save
Save Context
Code Demo
Migration
• Lightweight Migration
• Model versioning
Lightweight migration
• Adding or removing entity, relation or attribute
• Making attribute non optional
• Making non optional attribute optional
• Renaming an atribute or entity
Lightweight migration
Model Versioning
Model Versioning
Model Versioning
Code Demo
Threading• Must create a new
NSManagedObjectContext for each thread
• NSManagedObjects are associated with a particular context
• NSManagedObjectContext can be updated with changes from other contexts
Code Demo
Core Data and iCloud
• Enabling
• Add iCloud Persistent Store
Enabling iCloud
Enabling iCloud
iCloud Persistent Store
Resources
• Core Data Programming Guide
• Core Data Model Versioning and Data Migration
• iCloud Programming Guide for Core Data
• iCloud Design Guide
• Code Sample https://github.com/TAGonSoft/CoreData_CodeCamp
Q & A
Thank You
Please feel the evaluation form
A Core Data Journey
Alex Terente
TAGonSoft.com