Database Reference
In-Depth Information
The filter screen is divided into three sections: Price, Most Popular and Sort By.
That last section is not technically made up of “filters,” but sorting usually goes
hand in hand with filters, so we'll leave it like that. :]
Below each price filter is space for the total number of venues that fall into that
price category. Similarly, there's a spot for the total number of deals across all
venues. You'll implement these next.
Returning a count
Open FilterViewController.swift and, as always, import the Core Data framework
at the top of the file:
import CoreData
Then add the following property below the last @IBOutlet property:
var coreDataStack: CoreDataStack !
This will hold the CoreDataStack object you've been using in the app delegate and in
ViewController.swift .
Switch to ViewController.swift and make the following modification to the already
implemented prepareForSegue :
override func prepareForSegue(segue: UIStoryboardSegue ,
sender: AnyObject ?) {
if segue. identifier == "toFilterViewController" {
let navController = segue. destinationViewController
as UINavigationController
let filterVC = navController. topViewController
as FilterViewController
//add the line below
filterVC. coreDataStack = coreDataStack
}
}
The new line of code propagates the CoreDataStack object from ViewController to
FilterViewController . The filter screen is now ready to use Core Data.
Go back to FilterViewController.swift and add the following lazy property:
lazy var cheapVenuePredicate: NSPredicate = {
var predicate =
NSPredicate (format: "priceInfo.priceCategory == %@" , "$" )
return predicate
Search WWH ::




Custom Search