Database Reference
In-Depth Information
selectedSortDescriptor
=
priceSortDescriptor
Like before, this
switch
statement matches the cell the user tapped with the
appropriate sort descriptor, so that it's ready to pass to the delegate when the user
taps Search.
The only wrinkle is the
nameZA
sort descriptor. Rather than creating a separate sort
descriptor, you can reuse the one for A-Z and simply call the method
reversedSortDescriptor
. How handy!
Everything else is hooked up for you to test the sorts you just implemented. Build
and run the sample app and go to the Filter screen. Tap the
Z-A name filter
and
then tap
Search
. You'll see search results ordered like so:
No, you're not seeing double. There really are six Vivi Bubble Tea venues in the
data set—it's a popular bubble tea chain in NYC. As you scroll down the table view,
you'll see that the app has indeed sorted the venues alphabetically from Z to A.
Woo-hoo!
You've now completed your Filter screen, setting it up such that the user can
combine any one filter with any one sort. Try different combinations to see what
you get. The venue cell doesn't show much information, so if you need to verify a
sort, you can go straight to the source and consult
seed.json
.
Asynchronous fetching
If you've gotten this far, there's both good news and bad news (and then more
good news). The good news it that you've learned a lot about what you can do with
a plain, old
NSFetchRequest
. The bad news is that every fetch request you've