subinspathilettu / SJSegmentedViewController

MIT License
334 stars 126 forks source link

Data passing #144

Open pramodshukla1011 opened 4 years ago

pramodshukla1011 commented 4 years ago

How can we pass data from 1st segment controller to the header view controller

ZacharyKhan commented 4 years ago

Hello Pramod, I would suggest using a protocol and having your segmented view controller conform to this protocol. You can use this to pass data.

protocol HeaderViewControllerDelegate: AnyObject {
   func passDataToHeader() -> data: Any
}
class SegmentedViewController: UIViewController, HeaderViewControllerDelegate {
   weak var delegate: HeaderViewControllerDelegate?

   func passDataToHeader() {
      // logic for assembling data here
      return data
   }
}