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.
Short description
Adds a method
Context.count<T>
and implement it in theNSManagedObjectContext
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
Context.count<T: Entity>(_:) throws -> Int
;NSManagedObjectContext
with other protocol requirements.GIF
CoreData with brand new
count
method:...that gives 02 (two)
UserEntity
instances.