Core Data Best Practices

WWDC 2018

Posted by Den on July 20, 2018 · 8 mins read
Core Data Best Practices

Core Data Best Practices

WWDC 2018

Core Data Best Practices

WWDC 2018

Core Data Manages Persistence

How the container Finds Models

More Container Tricks

Customizing where stores are stored

Generalizing Controllers

  • Getting view controllers what they need when using

Matching UIs to the Model

Managed Object ContextWillSave Notification

  • Posts that have been inserted/ deleted

Managing Growth

  • More complecated → Chaos → Bad UX
  • Query generations helps you
Chaos

Query generations (WWDC 2016)

  • Isolate contexts from completing work
  • Provide a consistent, durable view of the database
  • Requires WAL journal mode
Synchronized

Filtering Updates with Persistent History Tracking

  • New in iOS 11 and macOS 10.13
  • Persisted record of each transaction

Bulk Editing with Batch Operations

NSManagedObject.delete vs NSBatchDeleteRequest

Adopt NSSecureUnarchiveFromDataTransformerName

  • Old — nil or NSKeyedUnarchiveFromDataTrasnformerName
  • New — NSSecureUnarchiveFromDataTransformerName

Transparent for plist types

  • Custom classes need a custom transformer

CoreData Debug Log

Performance Analysis with sqlite3


Better Indexing

Testing With CoreData