SugarRecord icon indicating copy to clipboard operation
SugarRecord copied to clipboard

Adding Count operation to Context

Open LuizZak opened this issue 7 years ago • 0 comments

Short description

Adds a method Context.count<T> and implement it in the NSManagedObjectContext extension.

Solution

Counting number of results without getting the objects is a useful functionality, specially when the objects are heavy-weight to fetch simply to be counted and then discarded.

Implementation

  • [√] Add new protocol method Context.count<T: Entity>(_:) throws -> Int;
  • [√] Implement this protocol on existing extension of NSManagedObjectContext with other protocol requirements.

GIF

CoreData with brand new count method:

200

...that gives 02 (two) UserEntity instances.

LuizZak avatar Jun 04 '17 18:06 LuizZak