Created
January 25, 2015 14:33
-
-
Save crazytonyli/5b0bbef739097a4856fe to your computer and use it in GitHub Desktop.
UITextField+BlocksKit crashes this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void -[EditUserWordController viewDidAppear:](void * self, void * _cmd, bool arg2) { | |
rbx = self; | |
var_28 = rbx; | |
var_20 = *0x2bd50; | |
LODWORD(rdx) = LOBYTE(arg2) & 0xff; | |
[[var_28 super] viewDidAppear:rdx]; | |
if ([[rbx targetTextField] delegate] != rbx) { | |
r15 = *objc_msgSend; | |
rdx = [[rbx targetTextField] delegate]; | |
[rbx setOriginalTargetDelegate:rdx]; | |
rdx = [[rbx shortcutTextField] delegate]; | |
[rbx setOriginalShortcutDelegate:rdx]; | |
rax = [rbx targetTextField]; | |
[rax setDelegate:rbx]; | |
rax = [rbx shortcutTextField]; | |
rdx = rbx; | |
[rax setDelegate:rdx]; | |
} | |
r15 = *objc_msgSend; | |
r14 = [rbx targetTextField]; | |
if ([[r14 text] length] != 0x0) { | |
rax = [rbx _shouldSetDefaultFirstResponder]; | |
if ((LOBYTE(rax) != 0x0) || ([[[rbx shortcutTextField] text] length] == 0x0)) { | |
r15 = *objc_msgSend; | |
rax = [rbx shortcutTextField]; | |
[rax becomeFirstResponder]; | |
} | |
} | |
else { | |
[r14 becomeFirstResponder]; | |
} | |
r15 = *objc_msgSend; | |
r14 = [[rbx navigationItem] rightBarButtonItem]; | |
rax = [rbx shortcutTextField]; | |
rax = [rax text]; | |
rax = [rax length]; | |
rax = [r14 setEnabled:LOBYTE(rax != 0x0 ? 0x1 : 0x0) & 0xff]; | |
return; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TextFieldViewController.h | |
// BKDemo | |
// | |
// Created by Tony Li on 1/25/15. | |
// Copyright (c) 2015 Tony Li. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface TextFieldViewController : UIViewController<UITextFieldDelegate> | |
@property (nonatomic, readonly) UITextField *textField; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TextFieldViewController.m | |
// BKDemo | |
// | |
// Created by Tony Li on 1/25/15. | |
// Copyright (c) 2015 Tony Li. All rights reserved. | |
// | |
#import "TextFieldViewController.h" | |
@interface SomeTextFieldDelegate : NSObject<UITextFieldDelegate> | |
@end | |
@implementation SomeTextFieldDelegate | |
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField | |
{ | |
return YES; | |
} | |
@end | |
static SomeTextFieldDelegate *textFieldDelegate; | |
@implementation TextFieldViewController { | |
id<UITextFieldDelegate> _originalDelegate; | |
} | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.view.backgroundColor = [UIColor whiteColor]; | |
_textField = [[UITextField alloc] init]; | |
_textField.borderStyle = UITextBorderStyleRoundedRect; | |
textFieldDelegate = [SomeTextFieldDelegate new]; | |
_textField.delegate = textFieldDelegate; | |
_textField.bounds = CGRectMake(0, 0, self.view.bounds.size.width - 20, 44); | |
_textField.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds)); | |
[self.view addSubview:_textField]; | |
// `_originalDelegate` should be `textFieldDelegate` which is setted in line 39. | |
// But actually it is an instance of `A2DynamicUITextFieldDelegate`. | |
_originalDelegate = _textField.delegate; | |
_textField.delegate = self; | |
[_textField becomeFirstResponder]; | |
} | |
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField | |
{ | |
return [_originalDelegate textFieldShouldBeginEditing:textField]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment