Managed

public protocol Managed : NSFetchRequestResult

A protocol for objects that are managed by a CoreData NSManagedObjectContext

  • The name of the model that defines instances of the managed type

    Declaration

    Swift

    static var entityName: String { get }
  • defaultSortDescriptors Default implementation

    Ordering for instances fetched from the persistent container. By default there is no ordering.

    Default Implementation

    Default sort definition

    Declaration

    Swift

    static var defaultSortDescriptors: [NSSortDescriptor] { get }
  • FetchRequest Extension method

    Undocumented

    Declaration

    Swift

    public typealias FetchRequest = NSFetchRequest<Self>
  • FetchConfigurator Extension method

    Undocumented

    Declaration

    Swift

    public typealias FetchConfigurator = (FetchRequest) -> Void
  • Initializer Extension method

    Undocumented

    Declaration

    Swift

    public typealias Initializer = (Self) -> Void
  • typedFetchRequest Extension method

    Obtain generic fetch request

    Declaration

    Swift

    public static var typedFetchRequest: FetchRequest { get }
  • sortedFetchRequest Extension method

    Obtain a fetch request that is sorted according to defaultSortDescriptors

    Declaration

    Swift

    public static var sortedFetchRequest: FetchRequest { get }
  • count(in:request:) Extension method

    Count the number of items returned by a given fetch request

    Declaration

    Swift

    public static func count(in context: NSManagedObjectContext, request: FetchRequest) -> Int

Available where Self: NSManagedObject

  • fetch(in:request:) Extension method

    Create a fetch request and execute it.

    Declaration

    Swift

    public static func fetch(in context: NSManagedObjectContext, request: FetchRequest) -> [Self]

    Parameters

    context

    the context where the managed objects live

    request

    what to request

    Return Value

    array of managed objects

  • Find or create a managed object

    Declaration

    Swift

    public static func findOrCreate(in context: NSManagedObjectContext, request: FetchRequest,
                                    initializer: Initializer) -> Self

    Parameters

    context

    the context where the managed objects live

    request

    what to request

    block

    code to run to initialize an object

    Return Value

    found/created managed object

  • findOrFetch(in:request:) Extension method

    Create a fetch request that returns the first item that matches a given predicate.

    Declaration

    Swift

    public static func findOrFetch(in context: NSManagedObjectContext, request: FetchRequest) -> Self?

    Parameters

    context

    the context where the managed objects live

    predicate

    the match definition

    Return Value

    optional found object

  • Obtain the first registered object in the context that matches a given predicate.

    Declaration

    Swift

    public static func materializedObject(in context: NSManagedObjectContext, matching predicate: NSPredicate?) -> Self?

    Parameters

    context

    the context where the managed objects live

    predicate

    the match definition

    Return Value

    optional found object

  • delete() Extension method

    Delete the managed object

    Declaration

    Swift

    public func delete()
  • appState Extension method

    Obtain the ManagedAppState singleton from the context associated with this entity

    Declaration

    Swift

    public var appState: ManagedAppState { get }