Database Reference
In-Depth Information
Next, re-implement the
saveButtonTapped
as shown below:
@IBAction
func
saveButtonTapped(sender:
UIBarButtonItem
) {
delegate
!.
filterViewController
(
self
,
didSelectPredicate:
selectedPredicate
,
sortDescriptor:
selectedSortDescriptor
)
dismissViewControllerAnimated
(
true
, completion:
nil
)
}
This means every time you tap Search in the top-right corner of the filter/sort
screen, you'll notify the delegate of your selection and dismiss the filter/sort screen
to reveal the list of venues behind it.
You need to make one more change in this file. Scroll down to
didSelectRowAtIndexPath
and implement it as shown below:
override
func
tableView(tableView:
UITableView
,
didSelectRowAtIndexPath indexPath:
NSIndexPath
) {
let
cell = tableView.
cellForRowAtIndexPath
(indexPath)!
switch
cell {
// Price section
case
cheapVenueCell
:
selectedPredicate
=
cheapVenuePredicate
case
moderateVenueCell
:
selectedPredicate
=
moderateVenuePredicate
case
expensiveVenueCell
:
selectedPredicate
=
expensiveVenuePredicate
default
:
println
(
"default case"
)
}
cell.
accessoryType
= .
Checkmark
}
When the user taps on any of the first three price category cells, this method will
map the selected cell to the appropriate predicate. You store a reference to this
predicate in
selectedPredicate
to have ready when you notify the delegate of the
user's selection.
Now, switch to
ViewController.swift
and make the following change to the class
declaration:
class
ViewController:
UIViewController
,