Skip to content

Add method that counts matching objects in fetch request #188

Closed
wants to merge 2 commits into from

3 participants

@mattbauch

It's probably a good idea to have a method that counts the matching objects of a fetchRequest.
In theory you could use the fetch method that returns a NSArray and count yourself, but countForFetchRequest:error: will be much faster.

Access to the substituted fetchRequest would be beneficial as well, especially if you create a NSFetchedResultsController or if you want to access the predicates defined in the model editor.

mattbauch added some commits Jan 24, 2014
@mattbauch mattbauch add ability to fetch object count for fetchRequests
This adds a count$YourFetchRequest method that invokes `[moc countForFetchRequest:error:]`
The fetchRequest creation was refactored into its own method.
Which made substitutionVariables unavailable in the fetchOne$Foo error message,
so it now displays the predicate of the fetchRequest.
5c90f7c
@mattbauch mattbauch make substituted fetchRequest creation method public
Should be useful to create NSFetchedResultsControllers or to create
compound predicates with existing predicates.
f3c107e
@Zyphrax
Zyphrax commented Jan 26, 2014

Looks nice, but perhaps we shouldn't add this to the default template.

A lot of people are using pods like MagicalRecord that make it easier to work with Core Data that already offer these kinds of methods. I would advise to keep the default template lean and clean.

@justin
Collaborator
justin commented Mar 22, 2016

We are declaring pull request and issue 0 now that 1.3 is out. If this is still an issue you'd like to see address with 1.30 and going forward, please open a new issue so we can start a fresh discussion. Thank you!

@justin justin closed this Mar 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.