I have a trigger that needs to insert a section controller somewhere in between the currently visible section controllers on screen. I can get the visible section controllers and their objects, however, I am unable to find their indices.
I'm trying something like this:
//model.content is [IGListDiffable]
let visibleControllers = adapter.visibleSectionControllers()
if let firstController = visibleControllers.first {
let section = adapter.section(for: firstController)
if let object = adapter.object(atSection: section) as? IGListDiffable,
let index = model.content.index(of: object) { // Doesn't work
...
}
}
But you can't use index(of:) with an IGListDiffable array. How can I do this? Thanks!
@yusuftor you already have the indices by getting the section of the section controller 馃槈
let section = adapter.section(for: controller)
let object = adapter.object(at: section)
// or
let object = adapter.objects()[section]
If you're trying to find the indices of the _items within the section controller_ that is a different story. Lmk if that is what you're trying to do. If that's the case, you should be doing that work inside the section controller.
Oops 馃槵 Thanks!