Observing changes in Core Data NSManagedObject instances with Combine publishers can be a great solution to keep your user interface in sync with the latest changes. After reading through my posts in the Combine and Core Data categories, you might know more about those individual frameworks, but how do you “combine” them together? Techniques like …
core data
Derived Attributes to improve Core Data Fetch Performance
Derived attributes are available since iOS 13 and aim to improve fetch performance in many different scenarios. Although we have great performance with the latest devices it’s good to be prepared for scaling up to fetching a large number of items from your database. Your memory footprint might look good now but once you start …
Constraints in Core Data Entities explained
Constraints in Core Data are part of an entity configuration. Settings like the entity name and Spotlight display name might be easy to understand while constraints are a bit less known. However, they can be super useful to maintain a unique set of data. Constraints can take away the need to filter out for existing …
NSManagedObject events: handling state in Core Data
An NSManagedObject lifecycle goes from insertion and updates until deletion in the end. All those events come with their own common related modifications and can be used in many different ways. Managing state in Core Data from within the NSManagedObject class itself is a great way to keep logic centralized. Updating a creation date, modified …
Persistent History Tracking in Core Data
WWDC 2017 introduced a new concept available from iOS 11 which is persistent history tracking. It’s Apple’s answer for merging changes that come from several targets like app extensions. Whenever you change something in your Core Data database from your Share Extension, a transaction is written which can be merged into any of your other …
Write-Ahead Logging (WAL) disabled to force commits in Core Data
Write-Ahead Logging is the default journaling mode for Core Data SQLite stores since iOS 7 and OS X Mavericks. Journaling in Core Data is best explained as the way data transactions are saved into the underlying SQLite store. The WAL mode is significantly faster in most scenarios compared to the previous default “rollback” journal mode …
ValueTransformer in Core Data explained: Storing absolute URLs
ValueTransformers in Core Data are a powerful way of transforming values before they get inserted into the database and before they get read. They’re set up in an abstract class which handles the value transformations from one representation to another. They’re often used as a way to store values that aren’t supported by default. Core …
Core Data and App extensions: Sharing a single database
Core Data got better and better over the years with improved APIs that make it easier to work with. The Apple framework allows you to save your application’s permanent data for offline use, to provide undo functionality or to simply cache data for better performance. After implementing the basics into your app like using a …
Core Data Debugging in Xcode using launch arguments
Core Data is Appleās object graph management and persistency framework for iOS, macOS, watchOS, and tvOS. It’s around for a long time and therefore a great solution to use for persistent storage of structured data in your application. Core Data Debugging might be a bit hard, although some less-known functionalities in Xcode can help you …