Fix crash upon rotation while buttons are displayed#1
Fix crash upon rotation while buttons are displayed#1
Conversation
tylermann
left a comment
There was a problem hiding this comment.
Change looks good, just a few comments around block retain semantics.
| self.swipeOffset = 0; | ||
| self.swipeOffset = currentOffset; | ||
| _triggerStateChanges = prevValue; | ||
| __block MGSwipeTableCell *blockSelf = self; |
There was a problem hiding this comment.
using the __block here is effectively the same as just using the original self reference as it creates a strong reference when captured below in the block. It would be preferred to use __weak, as it will create an auto-niling weak reference see (https://developer.apple.com/library/content/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html) for more info
| __block MGSwipeTableCell *blockSelf = self; | ||
| [self setSwipeOffset:0 animated:NO completion:^{ | ||
| [blockSelf setSwipeOffset:currentOffset animated:NO completion:^{ | ||
| _triggerStateChanges = prevValue; |
There was a problem hiding this comment.
accessing this instance variable inside of the block also implicitly captures it as a strong reference. The recommended technique of accessing an instance variable like this inside a block is called "weak-strong dance". Where you use a weak reference as mentioned above and then convert it to a strong reference within the block and verify it is not nil before accessing the instance variable.
No description provided.