Skip to content

Instantly share code, notes, and snippets.

/// Something that can be created in a core data context, usually an `NSManagedObject`.
public protocol CDCreatable {
/// Creates this object in the context given.
///
/// - Parameter context: Managed object context.
/// - Remarks: Default constructor generated by `NSManagedObject`.
/// - Warning: When creating objects, use `init(createIn:)` instead as it may contain additional initilization logic.
init(context: NSManagedObjectContext)
/// Creates this object in the context given.
import SystemConfiguration
/// Service that provides information on network reachability with the ability to watch for changes and post corresponding
/// notifications.
public final class Reachability {
private var reachability: SCNetworkReachability
// MARK: - Life Cycle
/// Creates a new reachability service for the host given.
import CoreData
/// Manages Core Data Persistent History.
///
/// When using Core Data in multiple targets, e.g. an app as well as a file provider, it is crucial to merge changes from one
/// target into another because otherwise you would end up with inconsistent state. To that end, this Apple introduced
/// persistent history, which is a linear stream of changes that can be merged into the current context. This service takes
/// advantage of this feature by providing a simple interface for merging and deleting history. The latter is needed to free up
/// space after the history has been consumed by all targets. It uses history transactions' timestamps in order to determine
/// what to delete.