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

Add: check permit index path #27

Merged
merged 1 commit into from Mar 31, 2016
Merged

Add: check permit index path #27

merged 1 commit into from Mar 31, 2016

Conversation

bannzai
Copy link
Collaborator

@bannzai bannzai commented Mar 31, 2016

Why

I get out of bounds from Shoyu.Section func rowFor(row: Int) via UITableViewDelegate.didEndDisplayCell.
I faced this problem when I write that swift logic.

    class AnyTableViewController: UITableViewController {

        var elements: Element = // Elements ...

        func setupShoyu() {
        tableView.source = Source().createSection { section in
            section.createRows(elements) { row in
                ...
            }
        }



        func deleteElement(element: Element) { 
            elements.removeFrom(element) 
            setupShoyu() // Reset source.
            tableView.reloadData()  // Get out of bounds from this statement.
        }
    }

I thought removeElement and reset source then disappear corresponded cell.
But Shoyu.Section.rows.count is less than the past.
When get Shoyu.Section.row[indexPath.row], it would fall down.

What

I add Shoyu.Source.isPermitIndexPath function.
This function is check indexPath when didEndDisplayCell.
If not permit indexPath when early stage return.

@xai3
Copy link
Owner

xai3 commented Mar 31, 2016

👍 thx!

@xai3 xai3 merged commit 8f537d8 into xai3:master Mar 31, 2016
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

Successfully merging this pull request may close these issues.

None yet

2 participants