core data on ios n.
Skip this Video
Loading SlideShow in 5 Seconds..
Core Data on iOS PowerPoint Presentation
Download Presentation
Core Data on iOS

play fullscreen
1 / 24
Download Presentation

Core Data on iOS - PowerPoint PPT Presentation

stefan
272 Views
Download Presentation

Core Data on iOS

- - - - - - - - - - - - - - - - - - - - - - - - - - - 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