I'm trying to pass data two levels up from the xib into a VC so I can navigate to a separate view. I do get the data in the IGListKit Section but for some reason passDataFromSectionUp
function doesn't trigger the print("like")
function within the VC.
VC
class MainViewController: UIViewController, PassSectionDelegate {
func passDataFromSectionUp(sectionController: ExperiencesSectionController) {
print("Like"); //Doesn't trigger
}
IGListKit Section
protocol PassSectionDelegate: class {
func passDataFromSectionUp(sectionController: ExperiencesSectionController);
}
class ExperiencesSectionController: ListSectionController, UpdateDataDelegate {
weak var delegate: PassSectionDelegate? = nil;
func passUpdateData(data: String) {
print(data) //Data gets received
delegate?.passDataFromSectionUp(sectionController: self);
}
...
if let cell = cell as? CarouselControlCell {
cell.delegate = self;
}
xib
protocol UpdateDataDelegate: class {
func passUpdateData(data: String);
}
class CarouselControlCell: UICollectionViewCell {
weak var delegate: UpdateDataDelegate? = nil
@IBAction func addUpdate(_ sender: Any) {
delegate?.passUpdateData(data: "teeest");
}
The delegate: PassSectionDelegate
variable in your ExperiencesSectionController
class is set to nil, and was never updated given the code you shared. When calling delegate?.passDataFromSectionUp(sectionController: self)
, the delegate
variable will thus be identified as nil
and, subsequently, nothing will be executed.