What's New / App Services, Foundation & Diagnostics

What's new in CoreData

+15 NewiOS · macOS · tvOS · watchOS

Core Data is Apple's object graph and persistence framework. It manages model objects through types like NSManagedObjectContext and NSPersistentStoreCoordinator, and integrates with Spotlight indexing via NSCoreDataCoreSpotlightDelegate.

The 27 SDK adds 15 APIs with no deprecations or removals. New surface lands on NSManagedObjectContext, NSPersistentStoreCoordinator, and NSCoreDataCoreSpotlightDelegate. Several additions sit on NotificationCenter.MessageIdentifier, tying Core Data into the typed message-identifier API.

New

15
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.StoresDidChangeMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.StoresDidChangeMessage> {

    public static var storesDidChange: NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.StoresDidChangeMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.StoresDidChangeAsyncMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.StoresDidChangeAsyncMessage> {

    public static var storesDidChangeAsync: NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.StoresDidChangeAsyncMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.RemoteChangeMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.RemoteChangeMessage> {

    public static var remoteChange: NotificationCenter.BaseMessageIdentifier<NSPersistentStoreCoordinator.RemoteChangeMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSPersistentCloudKitContainer.EventChangedMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSPersistentCloudKitContainer.EventChangedMessage> {

    public static var eventChanged: NotificationCenter.BaseMessageIdentifier<NSPersistentCloudKitContainer.EventChangedMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.WillSaveMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.WillSaveMessage> {

    public static var willSave: NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.WillSaveMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveMessage> {

    public static var didSave: NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.ObjectsDidChangeMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.ObjectsDidChangeMessage> {

    public static var objectsDidChange: NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.ObjectsDidChangeMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveObjectIDsMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveObjectIDsMessage> {

    public static var didSaveObjectIDs: NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveObjectIDsMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveObjectIDsAsyncMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveObjectIDsAsyncMessage> {

    public static var didSaveObjectIDsAsync: NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidSaveObjectIDsAsyncMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidMergeChangesMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidMergeChangesMessage> {

    public static var didMergeChanges: NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidMergeChangesMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOStvOSwatchOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidMergeChangesAsyncMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidMergeChangesAsyncMessage> {

    public static var didMergeChangesAsync: NotificationCenter.BaseMessageIdentifier<NSManagedObjectContext.DidMergeChangesAsyncMessage> { get }
}
extension

NotificationCenter.MessageIdentifier

NewiOSmacOS
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSCoreDataCoreSpotlightDelegate.IndexDidUpdateMessage>
Declaration
extension NotificationCenter.MessageIdentifier where Self == NotificationCenter.BaseMessageIdentifier<NSCoreDataCoreSpotlightDelegate.IndexDidUpdateMessage> {

    public static var indexDidUpdate: NotificationCenter.BaseMessageIdentifier<NSCoreDataCoreSpotlightDelegate.IndexDidUpdateMessage> { get }
}
extension

NSCoreDataCoreSpotlightDelegate

NewiOSmacOS
extension NSCoreDataCoreSpotlightDelegate
Declaration
extension NSCoreDataCoreSpotlightDelegate {

    /// Posted when the Core Spotlight index is updated on a private queue.
    public struct IndexDidUpdateMessage : NotificationCenter.AsyncMessage {

        /// A type which you can optionally post and observe along with this `AsyncMessage`.
        public typealias Subject = NSCoreDataCoreSpotlightDelegate

        /// A optional name corresponding to this type, used to interoperate with notification posters and observers.
        public static let name: Notification.Name

        /// The UUID of the store that was indexed.
        public let storeUUID: String

        /// The persistent history token representing the index state.
        public let historyToken: NSPersistentHistoryToken?

        /// Converts a posted notification into this asynchronous message type for any observers.
        ///
        /// To implement this method in your own `AsyncMessage` conformance, retrieve values from the ``Notification``'s ``Notification/userInfo`` and set them as properties on the message.
        /// - Parameter notification: The posted ``Notification``.
        /// - Returns: The converted `AsyncMessage`, or `nil` if conversion is not possible.
        public static func makeMessage(_ notification: Notification) -> NSCoreDataCoreSpotlightDelegate.IndexDidUpdateMessage?

        /// Converts a posted asynchronous message into a notification for any observers.
        ///
        /// To implement this method in your own `AsyncMessage` conformance, use the properties defined by the message to populate the ``Notification``'s ``Notification/userInfo``.
        /// - Parameters:
        ///   - message: The posted `AsyncMessage`.
        /// - Returns: The converted ``Notification``.
        public static func makeNotification(_ message: NSCoreDataCoreSpotlightDelegate.IndexDidUpdateMessage) -> Notification
    }
}
extension

NSManagedObjectContext

NewiOSmacOStvOSwatchOS
extension NSManagedObjectContext
Declaration
extension NSManagedObjectContext {

    /// Posted before a main queue context saves.
    ///
    /// Only use this message type for contexts with `NSMainQueueConcurrencyType`.
    public struct WillSaveMessage : NotificationCenter.MainActorMessage {

        /// A type which you can optionally post and observe along with this `MainActorMessage`.
        public typealias Subject = NSManagedObjectContext

        /// A optional name corresponding to this type, used to interoperate with notification posters and observers.
        public static let name: Notification.Name

        public let context: NSManagedObjectContext

        /// Converts a posted notification into this main actor message type for any observers.
        ///
        /// To implement this method in your own `MainActorMessage` conformance, retrieve values from the ``Notification``'s ``Notification/userInfo`` and set them as properties on the message.
        /// - Parameter notification: The posted ``Notification``.
        /// - Returns: The converted `MainActorMessage` or `nil` if conversion is not possible.
        @MainActor public static func makeMessage(_ notification: Notification) -> NSManagedObjectContext.WillSaveMessage?

        /// Converts a posted main actor message into a notification for any observers.
        ///
        /// To implement this method in your own `MainActorMessage` conformance, use the properties defined by the message to populate the ``Notification``'s ``Notification/userInfo``.
        /// - Parameters:
        ///   - message: The posted `MainActorMessage`.
        /// - Returns: The converted ``Notification``.
        @MainActor public static func makeNotification(_ message: NSManagedObjectContext.WillSaveMessage) -> Notification
    }

    /// Posted after a main queue context saves.
    ///
    /// Only use this message type for contexts with `NSMainQueueConcurrencyType`.
    public struct DidSaveMessage : NotificationCenter.MainActorMessage {

        /// A type which you can optionally post and observe along with this `MainActorMessage`.
        public typealias Subject = NSManagedObjectContext

        /// A optional name corresponding to this type, used to interoperate with notification posters and observers.
        public static let name: Notification.Name

        public let context: NSManagedObjectContext

        /// Managed objects that were inserted during this save.
        public var inserted: Set<NSManagedObject> { get }

        /// Managed objects that were updated during this save.
        public var updated: Set<NSManagedObject> { get }

        /// Managed objects that were deleted during this save.
        public var deleted: Set<NSManagedObject> { get }

        /// Query generation token after the save.
        public let queryGeneration: NSQueryGenerationToken?

        public let historyToken: NSPersistentHistoryToken?

        /// Converts a posted notification into this main actor message type for any observers.
        ///
        /// To implement this method in your own `MainActorMessage` conformance, retrieve values from the ``Notification``'s ``Notification/userInfo`` and set them as properties on the message.
        /// - Parameter notification: The posted ``Notification``.
        /// - Returns: The converted `MainActorMessage` or `nil` if conversion is not possible.
        @MainActor public static func makeMessage(_ notification: Notification) -> NSManagedObjectContext.DidSaveMessage?

        /// Converts a posted main actor message into a notification for any observers.
        ///
        /// To implement this method in your own `MainActorMessage` conformance, use the properties defined by the message to populate the ``Notification``'s ``Notification/userInfo``.
        /// - Parameters:
        ///   - message: The posted `MainActorMessage`.
        /// - Returns: The converted ``Notification``.
        @MainActor public static func makeNotification(_ message: NSManagedObjectContext.DidSaveMessage) -> Notification
    }

    /// Posted when objects in a main queue context change (inserted, updated, deleted, refreshed, or invalidated).
    ///
    /// Only use this message type for contexts with `NSMainQueueConcurrencyType`.
    public struct ObjectsDidChangeMessage : NotificationCenter.MainActorMessage {

        /// A type which you can optionally post and observe along with this `MainActorMessage`.

Truncated.

extension

NSPersistentStoreCoordinator

NewiOSmacOStvOSwatchOS
extension NSPersistentStoreCoordinator
Declaration
extension NSPersistentStoreCoordinator {

    /// Posted when stores are added to or removed from the persistent store coordinator on the main queue.
    public struct StoresDidChangeMessage : NotificationCenter.MainActorMessage {

        /// A type which you can optionally post and observe along with this `MainActorMessage`.
        public typealias Subject = NSPersistentStoreCoordinator

        /// A optional name corresponding to this type, used to interoperate with notification posters and observers.
        public static let name: Notification.Name

        public let persistentStoreCoordinator: NSPersistentStoreCoordinator

        /// Stores that were added during this change.
        public var addedStores: [NSPersistentStore] { get }

        /// Stores that were removed during this change.
        public var removedStores: [NSPersistentStore] { get }

        public var uuidChangedStores: (oldValue: NSPersistentStore, newValue: NSPersistentStore)? { get }

        /// Converts a posted notification into this main actor message type for any observers.
        ///
        /// To implement this method in your own `MainActorMessage` conformance, retrieve values from the ``Notification``'s ``Notification/userInfo`` and set them as properties on the message.
        /// - Parameter notification: The posted ``Notification``.
        /// - Returns: The converted `MainActorMessage` or `nil` if conversion is not possible.
        @MainActor public static func makeMessage(_ notification: Notification) -> NSPersistentStoreCoordinator.StoresDidChangeMessage?

        /// Converts a posted main actor message into a notification for any observers.
        ///
        /// To implement this method in your own `MainActorMessage` conformance, use the properties defined by the message to populate the ``Notification``'s ``Notification/userInfo``.
        /// - Parameters:
        ///   - message: The posted `MainActorMessage`.
        /// - Returns: The converted ``Notification``.
        @MainActor public static func makeNotification(_ message: NSPersistentStoreCoordinator.StoresDidChangeMessage) -> Notification
    }

    /// Posted when stores are added to or removed from the persistent store coordinator on a background queue.
    public struct StoresDidChangeAsyncMessage : NotificationCenter.AsyncMessage {

        /// A type which you can optionally post and observe along with this `AsyncMessage`.
        public typealias Subject = NSPersistentStoreCoordinator

        /// A optional name corresponding to this type, used to interoperate with notification posters and observers.
        public static let name: Notification.Name

        public let persistentStoreCoordinator: NSPersistentStoreCoordinator

        /// Stores that were added during this change.
        public var addedStores: [NSPersistentStore] { get }

        /// Stores that were removed during this change.
        public var removedStores: [NSPersistentStore] { get }

        public var uuidChangedStores: (oldValue: NSPersistentStore, newValue: NSPersistentStore)? { get }

        /// Converts a posted notification into this asynchronous message type for any observers.
        ///
        /// To implement this method in your own `AsyncMessage` conformance, retrieve values from the ``Notification``'s ``Notification/userInfo`` and set them as properties on the message.
        /// - Parameter notification: The posted ``Notification``.
        /// - Returns: The converted `AsyncMessage`, or `nil` if conversion is not possible.
        public static func makeMessage(_ notification: Notification) -> NSPersistentStoreCoordinator.StoresDidChangeAsyncMessage?

        /// Converts a posted asynchronous message into a notification for any observers.
        ///
        /// To implement this method in your own `AsyncMessage` conformance, use the properties defined by the message to populate the ``Notification``'s ``Notification/userInfo``.
        /// - Parameters:
        ///   - message: The posted `AsyncMessage`.
        /// - Returns: The converted ``Notification``.
        public static func makeNotification(_ message: NSPersistentStoreCoordinator.StoresDidChangeAsyncMessage) -> Notification
    }

    /// Posted when a store receives a remote change notification from another process.
    public struct RemoteChangeMessage : NotificationCenter.AsyncMessage {

        /// A type which you can optionally post and observe along with this `AsyncMessage`.
        public typealias Subject = NSPersistentStoreCoordinator

        /// A optional name corresponding to this type, used to interoperate with notification posters and observers.
        public static let name: Notification.Name

Truncated.

No APIs match your filter.

← More in App Services, Foundation & Diagnostics