NSManagedObject

extension NSManagedObject
  • Aggregate operation.

    Perform aggregate operations on a set of values.

    Declaration

    Swift

    public static func aggregate(groupBy properties: [String]? = nil, for key: String, type: Aggregate, completion: ((NSFetchRequest<NSFetchRequestResult>) -> Void)? = nil) -> [[String : Any]]?

    Parameters

    properties

    Properties to group by.

    key

    Property to execute aggregate operation on.

    type

    Aggregate operation type.

    completion

    The block to execute when NSFetchRequest is created, for further customization.

  • Save changes if any.

    Calling this method will save all performed changes in the current context.

    Declaration

    Swift

    public func save(context: NSManagedObjectContext? = nil)

    Parameters

    context

    Specify which context to use to save changes, default is main context.

  • Delete current object.

    Declaration

    Swift

    public func delete(_ completion: ((Bool) -> Void)? = nil)

    Parameters

    completion

    The block to execute when deletion finishes. The block takes one parameter Bool, true if the request is success or false.