Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle multiple sections #116

Open
J-Arji opened this issue Sep 11, 2020 · 0 comments
Open

handle multiple sections #116

J-Arji opened this issue Sep 11, 2020 · 0 comments

Comments

@J-Arji
Copy link

J-Arji commented Sep 11, 2020

I want my tableview handle multiple sections with different Items.

my model is :

struct Object: Hashable, Comparable, Equatable {

    var index: Int
    var name: String
 
    var data: [Any]
}

and Object is section and data is row of cell

I went this way:

extension Object: Differentiable {

    var differenceIdentifier: String {
        return "\(index)"
    }

    func isContentEqual(to source: TypeStorableItem) -> Bool {
        index == source.index && name == source.name
    }
}

and in ViewController :

typealias AnyArraySection =  ArraySection<TypeStorableItem, AnyDifferentiable>

  var typeManager: [AnyArraySection] = []
    var inputTypeManager: [AnyArraySection] {
        get { typeManager }
        set {
            let changeset = StagedChangeset(source: typeManager, target: newValue)
            
            self.tableView.reload(using: changeset, with: .automatic) { data in
                self.typeManager = data
            }
        }
    }

when I want add item

let model = Object(index: index,
                                       name: identifier,
                                       data: data)
        item = ArraySection(model: model, elements: model.data)


how is it possible?
what about multiple sections with multiple types.

Detailed Description (Include Screenshots)

Environment

  • Library version:

  • Swift version:

  • iOS version:
    13

  • Xcode version:
    11.7

  • Devices/Simulators:

  • CocoaPods/Carthage version:

@J-Arji J-Arji changed the title handel multi section handle multiple sections Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant