I recently have just been able to populate my core data DB. I have an attribute named username and I would like to get the total number of users on the system (in the DB) and print it out. I know I need to use NSFetchRequest along with NSEntityDescription. I am just not sure how to go about it. I haven't really seen a question like this on SO. The entity is named Account and my attribute is labeled username
Asked
Active
Viewed 123 times
1 Answers
2
For your particular case, I suppose you have each username as a separate record so you can use the -countForFetchRequest:error:
method of NSManagedObjectContext
to get the number of objects a given fetch request would have returned if it had been passed to executeFetchRequest:error:

graver
- 15,183
- 4
- 46
- 62
-
you mean do something like this http://stackoverflow.com/questions/1611342/coredata-countforfetchrequest-says-entity-not-found – ipatch Jun 21 '12 at 09:43
-
got it working, i guess i'll give you the answer would have like to seen some written out code ... oh well. – ipatch Jun 21 '12 at 10:22