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

Better row deselection behavior during interactive transitions #406

Merged
merged 1 commit into from
May 6, 2016

Conversation

ZevEisenberg
Copy link
Contributor

Closes #405

tableView?.selectRowAtIndexPath($0, animated: false, scrollPosition: .None)
}

let deselectionAnimation = { (context: UIViewControllerTransitionCoordinatorContext) in
Copy link
Member

Choose a reason for hiding this comment

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

@ZevEisenberg [weak self] should be added in the closure, right? same applies to reselection closure. I can make these changes if you agree on them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mtnbarreto no need to [weak self], since you're in an animation block that self is not retaining. Only need [weak self] when the thing that the block is capturing (and therefore retaining) is also retaining the block. Here, the animation system is holding the block, and will eventually release it, which will then release the captured self.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. I'm not completely sure how swift manage these references and which one is released first. I've already added the [weak self], the result should be the same. Note that i didn't add it to foreach since it explicitly declare @noescape.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. A good rule of thumb is that if it's an animation block, and it's going to run once, then it's fine to not use [weak self]. If it's a repeating animation, more care must be taken, because the animation system will retain the block indefinitely, so you can't rely on canceling the animation in deinit (for example).

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