I’m currently working on an app that uses Core Data. The issue I’m dealing with is the fetch data with predicate, example shown below:
[[self managedObjectContext] fetchObjectsForEntityName:@"Employee" withPredicate:
@"(lastName LIKE[c] 'Worsley') AND (salary > %@)", minimumSalary];
What i want to do is fetch the number of different categories from a certain dataset like this:
Entity Person:
-Name (String)
-Location (String)
-Age (Int)
So if for example i have 3 samples in the dataset:
[Lisa, Sweden, 30] [Mike, USA, 24] [Jacob, England, 28]
I now want to fetch the number of different locations, is this possible?
Many Thanks
Robert
In the FetchResults controller method,add the following code.
From the documentation of returnsDistinctResults:
From the documentation of propertiesToFetch:
From the documentation of resultType: