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];
- iOS 6.1 simulator on OSX 10.10 Yosemite
- UIAlertView is Not Working in Swift
- NSIndexPath? does not have a member name 'row' error in Swift
- EXC_BAD_ACCESS Using IBInspectable
- Hide UITabBar when pushed while retaining touch
- Wrong language on native controls iOS HTML5 & Cordova app
- How to create a global environment variable that can be accessed by SpringBoard or other applications in the jailbroken iPhone?
- iOS 10.1 Simulator shows “Application May Slow Down Your iPhone”
- Store credit card using Stripe + Parse with cloud code
- localizeWithFormat and variadic arguments in Swift
- Cordova iOS Video tag Local File Source
- Developing for iOS on multiple computers, testing on a single device, advice?
- Swift Can't Import Sqlite3 iOS
- NSAttributedString background color and rounded corners
- Why do the pages blink/flicker after transitions in my jQuery Mobile PhoneGap app on iOS?