Skip to content

Commit

Permalink
Fixes possible memory leak for Keyboard notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mehfuzh committed Dec 19, 2013
1 parent 709e249 commit d57fe5c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions MHTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ @interface MHTextField()

@property (nonatomic, strong) NSMutableArray *textFields;

@property id keyboardDidShowNotificationObserver;
@property id keyboardWillHideNotificationObserver;
@property (weak) id keyboardDidShowNotificationObserver;
@property (weak) id keyboardWillHideNotificationObserver;

@end

Expand Down Expand Up @@ -281,11 +281,11 @@ - (void)textFieldDidBeginEditing:(NSNotification *) notification{

_textField = textField;

[self setKeyboardDidShowNotificationObserver:[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardDidShowNotification object:nil queue:nil usingBlock:^(NSNotification *note){
[self keyboardDidShow:note];
[self setKeyboardDidShowNotificationObserver:[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardDidShowNotification object:nil queue:nil usingBlock:^(NSNotification *notification){
[self keyboardDidShow:notification];
}]];
[self setKeyboardWillHideNotificationObserver:[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification object:nil queue:nil usingBlock:^(NSNotification *note){
[self keyboardWillHide:note];
[self setKeyboardWillHideNotificationObserver:[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification object:nil queue:nil usingBlock:^(NSNotification *notification){
[self keyboardWillHide:notification];
}]];

[self setBarButtonNeedsDisplayAtTag:textField.tag];
Expand Down

0 comments on commit d57fe5c

Please sign in to comment.