Querying max, min and other via Core Data
Is it possible to query the database for the max, min and other values using Core Data framework?
3 Solutions Collect From Internet About “Querying max, min and other via Core Data”
You can indeed have an
NSFetchRequest calculate such values. You need to set your fetch request to return
NSDictionaryResultType results, and create appropriate
NSExpressionDescription objects to describe the operations (e.g. min, max, sum, etc.) you’re after.
Take a look at the worked example in Apple’s Core Data Programming Guide: http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdFetching.html#//apple_ref/doc/uid/TP40002484-SW6 .
You can use query builder, which allows you write your requests like this:
NSDictionary *productTotalSumAndAveragePriceGroupedByCountries = [[[[[Product all ] aggregatedBy:@[ @[kAggregateSum, @"amount"], @[kAggregatorAverage, @"price"]] ] groupedBy:@[@"country"] ] having:predicate ] execute];
- “Redirect URI doesnot match registered redirect URI” in instagram integration in IOS app
- UITableView scrolling slow, memory leak issue
- detecting uibutton pressed in tableview: Swift Best Practices
- iOS 11 & iPhone X: UINavigationBar's toolbar spacing incorrect when embedded in UITabBarController
- UITableViewCell doesn't get deselected when swiping back quickly
- libxml/tree.h no such file or directory
- iPhone add inertia/momentum physics to animate “wheel of fortune” like rotating control
- iAd didFailToReceiveAdWithError not working sometimes, displays white box
- Install In-House iOS App wirelessly with manifest.plist does not work anymore with iOS 8
- Transitioning between transparent navigation bar to translucent
- How to have CMake show headers-that are not part of any binary target-in the IDE?
- Pass touch from UIScrollView to superview (UIButton)
- Programmatically lock iPhone screen in iOS 7
- no type named 'shared_ptr' in namespace 'std'
- Choosing 'Not Now' when accepting app causes “com.facebook.sdk error2”