I am using the following viewController setup
What I am trying to do is access an array of places from the placesTabBar and show them in the two navigationControllers. One of these controllers will contain a list of places while the other one will be used for only places you are attending. On selection of a cell it will update the other view controller when switched over to say that you are going to that place. I am using the following code:
AllPlaces ViewController
class AllPlaces: UITableViewController {
var delegate:placesTabBar!
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return delegate.placeDataArray.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
cell.textLabel?.text = delegate.placeDataArray[indexPath.row].description
return cell
}
}
AttendingPlaces ViewController class AttendingPlaces: UITableViewController {
var delegate:placesTabBar!
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return delegate.placeDataArray.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
cell.textLabel?.text = delegate.placeDataArray[indexPath.row].description
return cell
}
}
TabBarController
class placeData: Equatable {
var description : String
var selected : Bool
init (description : String, selected : Bool) {
self.description = description
self.selected = selected
}
}
class placesTabBar: UITabBarController, CustomTabBarDelegate {
var placeDataArray = Array<placeData>()
override func viewDidLoad() {
placeDataArray = [placeData(description: "Afghanistan", selected: false), placeData(description: "Albania", selected: false)]
var table1 = AttendingPlaces()
var table2 = AllPlaces()
table1.delegate = self
table2.delegate = self
var navController1 = UINavigationController(rootViewController: table1)
var navController2 = UINavigationController(rootViewController: table2)
self.viewControllers = [navController1, navController2]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Right now I am just trying to load the tables with the two places I have in the array. However, I am getting a "unable to dequeue a cell with identifier Cell" error. The reuse identifier is set properly in both tableViewControllers so i'm not sure what is going on. Could it be the way I am trying to share the data between the two viewControllers?

tableViewswere working before I tried to access the array from thetabBarViewControllerand then stopped once I implemented that code. I feel like that error could be misleading.