iosswiftinstagramiglistkit

How to pass multiple objects to IGListKit Section Controller


I'm using IGListStackedSectionController and I want to know how to pass multiple objects to any of given childs.

I have a scenario like this:

let sectionController = IGListStackedSectionController(sectionControllers: [
            WorkingRangeSectionController(),
            DisplaySectionController(),
            HorizontalSectionController(),
            ])!

Let's say I want to put a dynamic title on the first section, an array of images in the second section and a different array of images on the last section.

How would I do that?

Thanks a lot!


Solution

  • Short answer:

    You can't do this. Same object is passed to all subsection controllers.

    Long answer:

    You can combine all necessary data to a class, e.g.:

    class Model {
        var title = ""
        var images = [UIImage]()
        var otherImages = [UIImage]()
    }
    

    You also need to implement IGListDiffable protocol according to your needs.

    There is brief example of IGListStackedSectionController in IGListKit examples on GitHub.