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
/** | |
Returns the index paths of the rows affected by switching between two | |
sorted (but not necessarily unique) arrays. | |
@param old The array to be switched from. | |
@param new The array to be switched to. | |
@param keyPath the key path to compare ("@self" to use raw value) | |
@return An array of three arrays, the first containing index paths | |
for modified rows, the second for deleted rows, and the third for |
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
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { | |
if (textField == self.myPhoneTextField) { | |
NSString *newText = [textField.text stringByReplacingCharactersInRange:range withString:string]; | |
BOOL deleting = [newText length] < [textField.text length]; | |
NSString *stripppedNumber = [newText stringByReplacingOccurrencesOfString:@"[^0-9]" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, [newText length])]; | |
NSUInteger digits = [stripppedNumber length]; | |
if (digits > 10) | |
stripppedNumber = [stripppedNumber substringToIndex:10]; |
NewerOlder