1 / 24

Core Data on iOS

Core Data on iOS. Dhwanil Karwa. Topics. What is Core Data? Framework Overview Using Core Data Demo. 1. What is Core Data?. It is not a database. It is not an Object Relational Mapping framework.

stefan
Download Presentation

Core Data on iOS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Core Data on iOS Dhwanil Karwa

  2. Topics • What is Core Data? • Framework Overview • Using Core Data • Demo 1

  3. What is Core Data? • It is not a database. • It is not an Object Relational Mapping framework. • Apple explains it as “Core Data is a Schema driven object graph management and persistence Framework” • It creates a layer between database and UI. 1

  4. What is Core Data? • Performs CRUD operations • Queries values using NSPredicate • You don’t define the identity primary keys, only give relationships.

  5. Why learn Core Data? • Before Core Data, developers had to work with Sqlite3 to save data. • Handling CRUD operations was difficult. • User was responsible to check if saved data matched the schema. • Means you are writing your own persistence Layer • Using Core Data hides Sqlite3

  6. Storage Options • Binary • In-memory • XML only on Mac OS X • Sqlite

  7. Core Data vs. SQLite3

  8. Core Data M-VC Controller implements Strategy for the View View Controller Model Implements Observer Core Data

  9. Core Data Stack • Heart of Core Data • NSManagedObjectModel • NSPersistentStoreCoordinator • NSManagedObjectContext

  10. NSManagedObjectModel • Schema for Models • Entity, Attributes, Relationships • Fetch Requests • Validation

  11. NSManagedObjectModel Attribute Types • Integer, Decimal, Float, Double • Boolean • Date • String • Binary Data • Transformable

  12. NSManagedObjectModel Relationships • NSSet not NSArray • One to One • One to Many • Many to Many • Delete Rules • Nullify, Cascade, Deny

  13. NSManagedObjectModel

  14. NSPersistentStoreCoordinator • Coordinates access to one or more persistent stores. • Depends on Managed Object Model • Set store options

  15. NSPersistentStoreCoordinator

  16. NSManagedObjectContext

  17. Core Data Model Inspector

  18. Core Data Model Inspector

  19. Save Objects

  20. NSFetchRequest

  21. DEMO

  22. References • Apple Developer. 2012. Core Data Programming Guide https://developer.apple.com/library/mac/documentation/cocoa/conceptual/coredata/cdProgrammingGuide.html#//apple_ref/doc/uid/TP30001200-SW1 • Burkepile Adam. 2013. http://www.raywenderlich.com/934/core-data-tutorial-for-ios-getting-started

  23. Questions?

  24. Thank You

More Related