Search code examples
iosarraysjsonswiftcarbonkit

CarbonKit : How To pass tab array title ID to UIViewController?


enter image description hereI'm using CarbonKit in ViewController. Its working fine. Here, I'm using one tableview for all Segment Array title ID. And i got title ID when i was selected Tab and swipe, and stuck with passing array title ID to server(TableView) when i'll changing index from left ---> right & right ---> left.

My Code: Names Array

 self.carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: self.names as [AnyObject], delegate: self)

setting ViewController

 func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {

    studentid = studentidArray.object(at: Int(index)) as! String
    print(studentid)
    return self.storyboard!.instantiateViewController(withIdentifier: "LeaveTableVC") as! LeaveTableVC
}

I has shown names on 'ViewController' with 'tableview'. Now I need to send name of ID to server, when swipe and tap the segment tab. Please help i'm stuck. Thank you


Solution

  • Ok if I understand the thing is that your LeaveTableVC is the root view controller of the Carbon Kit controller, I think that would be better if you use a different TableViewController that could be the same for all your tabs, but anyway studentID is not your new LeaveTableVC instance property but is the current LeaveTableVC property. So for example you need to do:

    func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
        let nextVC = self.storyboard!.instantiateViewController(withIdentifier: "LeaveTableVC") as! LeaveTableVC
        nextVC.studentid = studentidArray.object(at: Int(index)) as! String
        print(studentid)
        return nextVC
    }