Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core data - Distinct values

I'm having trouble with core data and fetching distinct values. What I want to do is fetch records that are distinct by one property, but I want to fetch more than one property of a record. If I set setPropertiesToFetch:[NSArray arrayWithObject:@"firstAtrb", @"secondAtrb"] (more than one) then setReturnsDistinctValues:YES returns distinct values by properties defined in setPropertiesToFetch. Is it possible to define a property by which fetch should be distinct but at the same time define more than one property to fetch?

like image 877
paxx Avatar asked Aug 05 '26 16:08

paxx


1 Answers

here is a solution that i used on you can filter the results by distinct heres and example [myResults valueForKeyPath:@"@distinctUnionOfSets.foo"] and a the refrence link retrieving distinct values core data

like image 86
Alejandro Rangel Avatar answered Aug 07 '26 06:08

Alejandro Rangel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!