Database Reference
In-Depth Information
//add the line below
populateModerateVenueCountLabel
()
}
Build and run the sample project. As before, tap
Filter
on the top right to reach the
filter/sort screen:
Great news for bubble tea lovers! Only two places are moderately expensive.
Bubble tea as a whole seems to be quite accessible. :]
An alternate way to fetch a count
Now that you're familiar with
NSCountResultType
, it's a good time to mention that
there's an alternate API for fetching a count directly from Core Data.
Since there's one more price category count to implement, let's use this alternate
API now. Add the follow lazy property below the one you added previously:
lazy
var
expensiveVenuePredicate:
NSPredicate
= {
var
predicate =
NSPredicate
(format:
"priceInfo.priceCategory == %@"
,
"$$$"
)
return
predicate
}()
Now implement the following method below
populateModerateVenueCountLabel
:
func
populateExpensiveVenueCountLabel()
{
// $$$ fetch request
let
fetchRequest =
NSFetchRequest
(entityName:
"Venue"
)