3

as I have seen there are several possibilities to get an object count in core data(when I say an object count I mean the object count and just only the object count). If I set resultType to NSCountResultType, then what is better to do, executeFetchRequest:error: or countForFetchRequest:error:? Does the values of includesPropertyValues and includesSubentities care? Thanks

e1985
  • 6,239
  • 1
  • 24
  • 39

1 Answers1

4

If you only want a count of the objects that a fetch request would retrieve, call NSManagedObject's -countForFetchRequest:error:. It's easy enough to tell whether setting includesSubentities to YES makes a difference -- try it both ways and see. However, if I wanted to be certain that only those objects matching the request were counted, I'd start by setting that property to NO.

Caleb
  • 124,013
  • 19
  • 183
  • 272