通过核心数据查询最大值,最小值和其他值 [英] Querying max, min and other via Core Data
问题描述
是否可以使用Core Data框架查询数据库的max,min和其他值?
Is it possible to query the database for the max, min and other values using Core Data framework?
推荐答案
确实有一个 NSFetchRequest
计算这样的值。您需要设置您的获取请求以返回 NSDictionaryResultType
结果,并创建适当的 NSExpressionDescription
对象来描述操作,max,sum等)。
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.
查看Apple核心数据编程指南中的工作示例: http://developer.apple .com / library / mac / documentation / Cocoa / Conceptual / CoreData / Articles / cdFetching.html#// apple_ref / doc / uid / TP40002484-SW6 。
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 .
这篇关于通过核心数据查询最大值,最小值和其他值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!