Skip to content

Commit

Permalink
silenced pod lint warnings
Browse files Browse the repository at this point in the history
fixed possible retain cycles in code
  • Loading branch information
nitishmakhija committed Sep 28, 2018
1 parent ce8a456 commit 231de7d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 19 deletions.
34 changes: 25 additions & 9 deletions EasyTips/RCEasyTipView.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
//
// Created by Nitish Makhija on 16/12/16.
//
#define weakify(var) __weak typeof(var) AHKWeak_##var = var;

#define strongify(var) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
__strong typeof(var) var = AHKWeak_##var; \
_Pragma("clang diagnostic pop")

#import "RCEasyTipView.h"
#import "UIView+RCEssentials.h"
Expand Down Expand Up @@ -215,7 +222,7 @@ - (void)arrangeWithinSuperView:(UIView *)superView shouldUpdateWidth:(BOOL)updat
CGRect newFrame = [self computeFrameWithPosition:value.integerValue referenceFrame:refViewFrame superViewFrame:superViewFrame];
if ([self isFrame:newFrame forReferenceViewFrame:refViewFrame]) {
if (position != Any) {
NSLog(@"[EasyTipView - Info] The arrow position you chose %ld could not be applied. Instead, position <\(value)> has been applied! Please specify position ANY if you want EasyTipView to choose a position for you.", position);
NSLog(@"[EasyTipView - Info] The arrow position you chose %ld could not be applied. Instead, position <\(value)> has been applied! Please specify position ANY if you want EasyTipView to choose a position for you.", (long)position);
}
frame = newFrame;
position = value.integerValue;
Expand Down Expand Up @@ -423,7 +430,9 @@ - (void)drawTextWithFrame:(CGRect)bubbleFrame andContext:(CGContextRef)context {
- (void)handleRotation:(NSNotification *)notification {
UIView *superView = self.superview;
if (superView) {
weakify(self);
[UIView animateWithDuration:0.3f animations:^{
strongify(self);
[self arrangeWithinSuperView:superView shouldUpdateWidth:((UIDevice *)notification.object).orientation == UIDeviceOrientationPortrait ? NO: YES];
[self setNeedsDisplay];
}];
Expand All @@ -434,10 +443,12 @@ - (void)handleRotation:(NSNotification *)notification {

- (void)handleTap:(UIGestureRecognizer *)gesture {
if (gesture.state == UIGestureRecognizerStateEnded) {
weakify(self);
[self dismissWithCompletion:^{
strongify(self);
//remove all the gsture here
[self removeGestureRecognizer:gesture];
[_dismissOverlay removeGestureRecognizer:gesture];
[self.dismissOverlay removeGestureRecognizer:gesture];
}];
}
}
Expand Down Expand Up @@ -484,18 +495,21 @@ - (void)showAnimated:(BOOL)animated forView:(UIView *)view withinSuperView:(UIVi
_ID = [RCEasyTipViewIDGenerator getUniqueViewID];

if (animated) {
weakify(self);
[UIView animateWithDuration:_preferences.animating.showDuration
delay:0
usingSpringWithDamping:damping
initialSpringVelocity:velocity
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
strongify(self);
self.transform = finalTransform;
self.alpha = 1;
}
completion:^(BOOL finished) {
if (_delegate && [_delegate respondsToSelector:@selector(didShowTip:)]) {
[_delegate didShowTip:self];
strongify(self)
if (self.delegate && [self.delegate respondsToSelector:@selector(didShowTip:)]) {
[self.delegate didShowTip:self];
}
}];
}
Expand All @@ -515,22 +529,24 @@ - (void)dismissWithCompletion:(void (^)(void))completionBlock {
if (_dismissOverlay) {
[_dismissOverlay removeFromSuperview];
}

weakify(self);
[UIView animateWithDuration:_preferences.animating.dismissDuration
delay:0
usingSpringWithDamping:damping
initialSpringVelocity:velocity
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
self.transform = _preferences.animating.dismissTransform;
self.alpha = _preferences.animating.dismissFinalAlpha;
strongify(self);
self.transform = self.preferences.animating.dismissTransform;
self.alpha = self.preferences.animating.dismissFinalAlpha;
}
completion:^(BOOL finished) {
strongify(self);
if (completionBlock) {
completionBlock();
}
if (_delegate && [_delegate respondsToSelector:@selector(didDismissTip:)]) {
[_delegate didDismissTip:self];
if (self.delegate && [self.delegate respondsToSelector:@selector(didDismissTip:)]) {
[self.delegate didDismissTip:self];
}
[self removeFromSuperview];
self.transform = CGAffineTransformIdentity;
Expand Down
35 changes: 25 additions & 10 deletions Source/RCEasyTipView.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
//
// Created by Nitish Makhija on 16/12/16.
//
#define weakify(var) __weak typeof(var) AHKWeak_##var = var;

#define strongify(var) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
__strong typeof(var) var = AHKWeak_##var; \
_Pragma("clang diagnostic pop")

#import "RCEasyTipView.h"
#import "UIView+RCEssentials.h"
Expand Down Expand Up @@ -215,7 +222,7 @@ - (void)arrangeWithinSuperView:(UIView *)superView shouldUpdateWidth:(BOOL)updat
CGRect newFrame = [self computeFrameWithPosition:value.integerValue referenceFrame:refViewFrame superViewFrame:superViewFrame];
if ([self isFrame:newFrame forReferenceViewFrame:refViewFrame]) {
if (position != Any) {
NSLog(@"[EasyTipView - Info] The arrow position you chose %ld could not be applied. Instead, position <\(value)> has been applied! Please specify position ANY if you want EasyTipView to choose a position for you.", position);
NSLog(@"[EasyTipView - Info] The arrow position you chose %ld could not be applied. Instead, position <\(value)> has been applied! Please specify position ANY if you want EasyTipView to choose a position for you.", (long)position);
}
frame = newFrame;
position = value.integerValue;
Expand Down Expand Up @@ -423,7 +430,9 @@ - (void)drawTextWithFrame:(CGRect)bubbleFrame andContext:(CGContextRef)context {
- (void)handleRotation:(NSNotification *)notification {
UIView *superView = self.superview;
if (superView) {
weakify(self);
[UIView animateWithDuration:0.3f animations:^{
strongify(self);
[self arrangeWithinSuperView:superView shouldUpdateWidth:((UIDevice *)notification.object).orientation == UIDeviceOrientationPortrait ? NO: YES];
[self setNeedsDisplay];
}];
Expand All @@ -434,10 +443,12 @@ - (void)handleRotation:(NSNotification *)notification {

- (void)handleTap:(UIGestureRecognizer *)gesture {
if (gesture.state == UIGestureRecognizerStateEnded) {
weakify(self);
[self dismissWithCompletion:^{
strongify(self);
//remove all the gsture here
[self removeGestureRecognizer:gesture];
[_dismissOverlay removeGestureRecognizer:gesture];
[self.dismissOverlay removeGestureRecognizer:gesture];
}];
}
}
Expand Down Expand Up @@ -484,18 +495,21 @@ - (void)showAnimated:(BOOL)animated forView:(UIView *)view withinSuperView:(UIVi
_ID = [RCEasyTipViewIDGenerator getUniqueViewID];

if (animated) {
weakify(self);
[UIView animateWithDuration:_preferences.animating.showDuration
delay:0
usingSpringWithDamping:damping
initialSpringVelocity:velocity
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
strongify(self);
self.transform = finalTransform;
self.alpha = 1;
}
completion:^(BOOL finished) {
if (_delegate && [_delegate respondsToSelector:@selector(didShowTip:)]) {
[_delegate didShowTip:self];
strongify(self)
if (self.delegate && [self.delegate respondsToSelector:@selector(didShowTip:)]) {
[self.delegate didShowTip:self];
}
}];
}
Expand All @@ -515,27 +529,28 @@ - (void)dismissWithCompletion:(void (^)(void))completionBlock {
if (_dismissOverlay) {
[_dismissOverlay removeFromSuperview];
}

weakify(self);
[UIView animateWithDuration:_preferences.animating.dismissDuration
delay:0
usingSpringWithDamping:damping
initialSpringVelocity:velocity
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
self.transform = _preferences.animating.dismissTransform;
self.alpha = _preferences.animating.dismissFinalAlpha;
strongify(self);
self.transform = self.preferences.animating.dismissTransform;
self.alpha = self.preferences.animating.dismissFinalAlpha;
}
completion:^(BOOL finished) {
strongify(self);
if (completionBlock) {
completionBlock();
}
if (_delegate && [_delegate respondsToSelector:@selector(didDismissTip:)]) {
[_delegate didDismissTip:self];
if (self.delegate && [self.delegate respondsToSelector:@selector(didDismissTip:)]) {
[self.delegate didDismissTip:self];
}
[self removeFromSuperview];
self.transform = CGAffineTransformIdentity;
}];
}

@end

0 comments on commit 231de7d

Please sign in to comment.