π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± π± :scream
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; | |
view.backgroundColor = [UIColor redColor]; | |
self.textField.rightView = view; | |
self.textField.rightViewMode = UITextFieldViewModeUnlessEditing; | |
} |
The following line omitted the text in bold:
button.enabled = [string length]
> 0;
As a result, the string's length, a value of type NSUInteger, or unsigned long on 64-bit, was stuffed into a BOOL, which is actually a typedef for signed char. Comparisons of this frankenbool against NO yield the right result, but only for values below 255. Anything above might truncate and yield an erroneous NO. Comparing against YES, meanwhile, only returns the right result for the value 1. By setting the button's enabled state to an unsigned integer, the code was effectively disabling the button for all strings shorter or longer than one character.