I have a Core Data model of cars created and I'd like select one of vehicle type PLUS any of several different colors Here's what I envision to do this:
Selection ViewController
1) Select the type of car (sedan, coupe, SUV, hybrid) (I envision a segmented control to set this as a predicate)
2) Once the type of vehicle is selected, I'd like to select from a list of colors and display only cars that satisfy the type of vehicle I selected in the first step. For example, I'd like to display only SUVs that are (red, green, and blue) or only hybrids that are black and white.
Results TableViewController
3) Once those are selected, I'd like to dump them on another TVC.
This post helps a bit, but person asking the question trying to find disparate items (ex: A, B, & C). I'm trying to find X, Y & Z within only A. Can I apply multiple predicates to an NSFetchRequest? Would it be better to manually parse my results?
I'm running into trouble when I try retrieve one type of vehicle plus a list of selected colors
let vehiclePredicate = NSPredicate(format: "type == %@", "(one of sedan/coupe/SUV/hybrid)")
AND any of the following criteria
let colorRedPredicate = NSPredicate(format: "color == %@", "red")
let colorGreenPredicate = NSPredicate(format: "color == %@", "green")
let colorBluePredicate = NSPredicate(format: "color == %@", "red")
let colorBlackPredicate = NSPredicate(format: "color == %@", "black")
let colorWhitePredicate = NSPredicate(format: "color == %@", "white")
let colorPredicates: NSArray = [**add colors here when they're selected**]
I'm trying to figure out the cleanest way to do this, but the examples I've found only retrieve disparate items.
The other roadblock I've run into is how to get the results from my SelectionVC to the ResultsTVC. I know I'm going to need a delegate, but what will I need? Any assistance on this would be greatly appreciated.