UITableView Catégorie Array-Down -Swift iOS

J'ai 3 controllers de vue: FirstVC pour créer 9 éléments, SecondVC est une tableView pour sortinger ces éléments par nom de catégorie / id et afficher les deux, et ThirdVC est une tableView pour extraire et montrer les éléments à l'intérieur de cette catégorie. J'essaye d'implémenter un drill-down de tableView pour le faire mais le secondVC et le thirdVC m'a bloqué.

C'est le résultat que je cherche:

FirstVC

-9 objects : 3 Red objects Cherry, Tomato, Ruby 3 Green objects Cucumber, Broccoli, Emerald 3 Blue objects Blueberries, Sky, Sapphire 1.create all 9 objects 2.the object color and/or id determine which category each object belongs in the secondVC //There is no need to display anything on this scene 

SecondVC

 -3 cells: -Red -Green -Blue //this is where I'm stumped 1.tableView that sorts all 9 objects based on their color and/or id 2.right now all 9 cells are displaying but I would only like 3 cells to show only each individual category name and id 

ThirdVC

 -3 more cells Cherry Tomato Ruby 1.If you pressed the Red category cell in the secondVC then these 3 cells above would show inside the thirdVC. Same concept for the Blue and Green cells 

Objet de model de données

 class ColorClass: NSObject{ var colorCategoryName: Ssortingng? var colorID: Ssortingng? var realWorldObject: Ssortingng? } 

Mon premier controller de vue instancie 9 objects différents de ce model de données

 import UIKit class FirstViewController: UIViewController { var firstColorArray = [ColorClass]() override func viewDidLoad() { super.viewDidLoad() let redColor0 = ColorClass() redColor0.colorCategoryName = "red" redColor0.colorID = "0000" redColor0.realWorldObject = "Cherry" self.firstColorArray.append(redColor0) let redColor1 = ColorClass() redColor1.colorCategoryName = "red" redColor1.colorID = "0000" redColor1.realWorldObject = "Tomato" self.firstColorArray.append(redColor1) let redColor2 = ColorClass() redColor2.colorCategoryName = "red" redColor2.colorID = "0000" redColor2.realWorldObject = "Ruby" self.firstColorArray.append(redColor2) let greenColor0 = ColorClass() greenColor0.colorCategoryName = "green" greenColor0.colorID = "1000" greenColor0.realWorldObject = "Cucumber" self.firstColorArray.append(greenColor0) let greenColor1 = ColorClass() greenColor1.colorCategoryName = "green" greenColor1.colorID = "1000" greenColor1.realWorldObject = "Broccoli" self.firstColorArray.append(greenColor1) let greenColor2 = ColorClass() greenColor2.colorCategoryName = "green" greenColor2.colorID = "1000" greenColor2.realWorldObject = "Emerald" self.firstColorArray.append(greenColor2) let blueColor0 = ColorClass() blueColor0.colorCategoryName = "blue" blueColor0.colorID = "2000" blueColor0.realWorldObject = "Blueberries" self.firstColorArray.append(blueColor0) let blueColor1 = ColorClass() blueColor1.colorCategoryName = "blue" blueColor1.colorID = "2000" blueColor1.realWorldObject = "Sky" self.firstColorArray.append(blueColor1) let blueColor2 = ColorClass() blueColor2.colorCategoryName = "blue" blueColor2.colorID = "2000" blueColor2.realWorldObject = "Sapphire" self.firstColorArray.append(blueColor2) } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "segueToSecondVC"{ let secondVC = segue.destinationViewController as! SecondViewController secondVC.colorCategoryNameArray = self.firstColorArray } } } 

Mon SecondVC pour classr les objects

 import UIKit class SecondViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var tableView: UITableView! var colorCategoryNameArray = [ColorClass]() override func viewDidLoad() { super.viewDidLoad() } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.colorCategoryNameArray.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("colorCategoryNameCell", forIndexPath: indexPath) let rowIndex = self.colorCategoryNameArray[indexPath.row] cell.textLabel?.text = rowIndex.colorCategoryName cell.detailTextLabel?.text = rowIndex.colorID return cell } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { let cell = sender as! UITableViewCell let selectedRow = tableView.indexPathForCell(cell)?.row let thirdTableVC = segue.destinationViewController as! ThirdViewController thirdTableVC.realWorldObjectArray = [colorCategoryNameArray[selectedRow!]] } } 

My ThirdVC pour afficher les 3 objects dans chaque catégorie

 import UIKit class ThirdViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var tableView: UITableView! var realWorldObjectArray = [ColorClass]() override func viewDidLoad() { super.viewDidLoad() } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.realWorldObjectArray.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("realWordObjectCell", forIndexPath: indexPath) let rowIndex = self.realWorldObjectArray[indexPath.row] cell.textLabel?.text = rowIndex.realWorldObject return cell } }