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

Make it possible to map between sections even if they're empty #660

Merged
merged 3 commits into from
Nov 3, 2017

Conversation

Adlai-Holler
Copy link
Member

Previously, there was no native way to map between sections. So our best shot was to pick item 0 and translate its index path, and then read the section index. This has a couple of failure modes:

  • There is no item 0 in the "from" map (empty section)
  • Item 0 is deleted, reloaded, or moved in the change

To fix this and provide more direct section tracking, we:

  • Always create ASSection objects, even if the data source provides no context for them.
  • Do the mapping between these. It's fast O(N) – shouldn't be an issue.

In the future I hope we can go further with ASSection but this is a good start.

@@ -64,8 +64,6 @@
return __val; \
}

#define ASIndexPathForSection(section) [NSIndexPath indexPathForItem:0 inSection:section]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this macro because using item 0 is only something that's done for flow layout headers and footers. In any other context, "index path for section" would mean a one-node index path.

Copy link
Member

@appleguy appleguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really big step forward for apps to seamlessly work across the view <-> model spaces. Thank you @Adlai-Holler; the change looks correct and I'll start testing it in detail.

@Adlai-Holler Adlai-Holler merged commit 4fc753a into master Nov 3, 2017
@Adlai-Holler Adlai-Holler deleted the AHBetterSections branch November 3, 2017 23:24
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
…reGroup#660)

* Make section mapping work even for empty sections

* Unlock more cases and update changelog

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

Successfully merging this pull request may close these issues.

None yet

2 participants