Skip to content

Commit

Permalink
Fixed strong delegate bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
tLewisII committed Nov 4, 2013
1 parent 9cb5503 commit 1020ef7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions TJLBarButtonMenu/Source/TJLBarButtonMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ typedef void (^TJLButtonTappedBlock)(TJLBarButtonMenu *buttonView, NSString *tit
*/
- (void)setButtonTappedBlock:(TJLButtonTappedBlock)block;

///The delegate
@property(weak, nonatomic) id <TJLButtonViewDelegate> delegate;
@end
4 changes: 2 additions & 2 deletions TJLBarButtonMenu/Source/TJLBarButtonMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ @interface TJLBarButtonMenu () {
@property(strong, nonatomic) NSMutableArray *firstConstraints;
@property(strong, nonatomic) UIViewController *parentView;
@property(strong, nonatomic) NSMutableArray *buttonArray;
@property(strong, nonatomic) id <TJLButtonViewDelegate> delegate;
@property(nonatomic) NSLayoutAttribute rightLeftPosition;
@property(nonatomic) NSLayoutAttribute initialButtonConstant;
@property(nonatomic) NSLayoutAttribute finalButtonConstant;
Expand Down Expand Up @@ -252,8 +251,9 @@ - (void)hide:(NSString *)buttonTitle {
[self layoutIfNeeded];
}
} completion:^(BOOL final) {
id<TJLButtonViewDelegate>strongDelegate = self.delegate;
if(buttonTappedBlock) buttonTappedBlock(self, buttonTitle);
if([self.delegate respondsToSelector:@selector(buttonMenu:titleForTappedButton:)]) [self.delegate buttonMenu:self titleForTappedButton:buttonTitle];
if([strongDelegate respondsToSelector:@selector(buttonMenu:titleForTappedButton:)]) [strongDelegate buttonMenu:self titleForTappedButton:buttonTitle];
[self removeFromSuperview];
}];
}];
Expand Down

0 comments on commit 1020ef7

Please sign in to comment.