What's new in CoreData?

Asked on 08/13/2024

1 search

In the latest WWDC, several updates and new features related to CoreData and SwiftData were introduced:

  1. SwiftData Enhancements: SwiftData, introduced with iOS 17, now uses CoreData by default to store information. It allows for custom data stores, enabling the use of alternative backends like SQLite or a remote web service. This flexibility is enhanced by the new datastore protocol, which supports any persistence backend. SwiftData also provides access to the history of changes in a datastore, which is useful for tracking local changes that need to be synced to a remote service.

  2. New Features in SwiftData:

    • Index and Unique Macros: These new macros help optimize queries by making them more efficient and preventing duplicate entries.
    • History API: This API allows tracking changes to your app's models, which is particularly useful for apps that need to sync data with remote services.
    • Custom Data Stores: SwiftData now supports custom data stores, allowing developers to use their own document formats or persistence backends.
  3. CoreData Coexistence: For those using CoreData, SwiftData history can now be used instead, providing a seamless transition and enhanced features for tracking changes.

For more detailed information, you can refer to the sessions:

These sessions provide a comprehensive overview of the new capabilities and improvements in SwiftData and its integration with CoreData.