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

Remove crash #73

Open
ilyatar opened this issue Mar 30, 2018 · 3 comments
Open

Remove crash #73

ilyatar opened this issue Mar 30, 2018 · 3 comments
Assignees
Labels

Comments

@ilyatar
Copy link

ilyatar commented Mar 30, 2018

Crash If remove all rows from section:
section.remove(rowFormers: section.rowFormers)
because it method is incorrect:

`public func remove(rowFormers: [RowFormer]) -> Self {

    var removedCount = 0
    for (index, rowFormer) in self.rowFormers.enumerated() {
        if rowFormers.contains(where: { $0 === rowFormer }) {
            remove(atIndex: index)  //REMOVE INSIDE CYCLE, COUNT OF ELEMENTS CHANGED EVERY ITERATION
            removedCount += 1
            if removedCount >= rowFormers.count {
                return self
            }
        }
    }
    return self
}`
@ilyatar
Copy link
Author

ilyatar commented Mar 30, 2018

It's right:

` public func remove(rowFormers: [RowFormer]) -> Self {

    for rowFormer in rowFormers {
        if let index = self.rowFormers.index(where: {$0 === rowFormer}) {
            remove(atIndex: index)
        }
    }
    
    return self
}

`

@cuongnv
Copy link

cuongnv commented Feb 21, 2019

Thank for reporting

@ZacharyKhan ZacharyKhan self-assigned this Jun 19, 2019
@ZacharyKhan
Copy link
Collaborator

Looking into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants