Database Reference
In-Depth Information
Note: What other functions does Core Data support? To name a few: count,
min, max, average, median, mode, absolute value and many more. For a
comprehensive list, check out Apple's documentation for NSExpression .
Fetching a calculated value from Core Data requires you to follow many, often
unintuitive steps, so make sure you have a good reason for using this technique—
like performance considerations.
Next, add the following line to the bottom of viewDidLoad :
populateDealsCountLabel ()
Build the sample project and head to the filter/sort screen to verify your changes:
Great! There are 12 total deals across all the venues that you have stored in Core
Data.
You've now used three of the four supported NSFetchRequest result types:
.ManagedObjectResultType , .CountResultType and .DictionaryResultType .
The remaining result type is .ManagedObjectIDResultType . When you fetch with this
type, the result is an array of NSManagedObjectID objects rather the actual managed
objects they represent. An NSManagedObjectID is a compact, universal identifier for a
managed object. It works like the primary key in the database!
Prior to iOS 5, fetching by IDs was popular because it conformed to the thread
confinement concurrency model. Now that thread confinement has been deprecated
in favor of more modern concurrency models, there's little reason to fetch by object
ID anymore.
Search WWH ::




Custom Search