a coredata journey

Post on 10-May-2015

172 Views

Category:

Mobile

1 Downloads

Preview:

Click to see full reader

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

• alex.terente@TAGonSoft.ro

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

Q & A

Thank You

Please feel the evaluation form

A Core Data Journey

Alex Terente

TAGonSoft.com

top related