Using NSFetchedResultsController and NSFetchRequest is it possible to setup a query that returns the highest value in each attribute.
For example:
Entity_001 A=F B=27 C=57
Entity_002 A=G B=23 C=98
Entity_003 A=X B=21 C=54
Entity_004 A=K B=11 C=27
Entity_005 A=R B=16 C=15
Result:
Entity_003 A=X B=21 C=54 // Biggest A
Entity_001 A=F B=27 C=57 // Biggest B
Entity_002 A=G B=23 C=98 // Biggest C
Essentially I have one data set and I need to pick out “the smallest”, “the fastest” and “the heaviest” I could do it manually without using NSFetchedResultsController, or I guess I could use 3 NSFetchedResultsControllers and try and mesh the results back into a single data source. Any ideas would be very much appreciated …
I would do 3 different fetch requests to return the highest value for each particular request, and then merge the object IDs of each particular fetch request result into an array, and perform the NSFetchedResultsController fetch (to have notifications from changes) with a fetch request that looks for the IDs of the objects inside the array. Basically, it’s 4 fetches. Three can be done in the background, one for the NSFetchedResultsController instance which will be done in the main thread.