Developer Area

Changeset 415

Show
Ignore:
Timestamp:
06/25/09 15:23:17 (5 years ago)
Author:
henri
Message:

Added support for automatically looking up ENUM numbers (+12125551212) in search field

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • apps/iphone/superbook/trunk/Classes/LocateThem_ViewController.m

    r414 r415  
    242242}        
    243243 
    244 #pragma mark ---- UISearchBar delegate and keyboard methods methods ---- 
     244#pragma mark ---- UISearchBar delegate and keyboard methods ---- 
    245245 
    246246- (void)keyboardWillShow:(NSNotification*)aNotification { 
     
    294294        if ([telSearch.text length] == 0) 
    295295                return; 
    296         // TODO: should make this faster by parsing the string char-by-char in C 
    297296        if ([telSearch.text hasPrefix:@"http"]) { 
    298297                telSearch.text = [telSearch.text stringByReplacingOccurrencesOfString:@"http://" withString:@""]; 
     
    302301                telSearch.text = [telSearch.text substringFromIndex:[@"www." length]]; 
    303302        } 
    304         if ([telSearch.text hasSuffix:@".tel"]) { 
     303        if ([telSearch.text hasPrefix:@"+"]) { 
     304                // Check if it's a phone number, try the sip version 
     305                BOOL isValidNumber = YES; 
     306                NSMutableString *enumStr = [NSMutableString stringWithCapacity:30]; 
     307                NSRange prefixR = NSMakeRange(0, 0); 
     308                for (int i = 1; i < [telSearch.text length]; i++) { 
     309                        unichar aChar = [telSearch.text characterAtIndex:i]; 
     310                        if ((aChar < 47) || (aChar > 58)) {     // Not in range of Unicode digits 0-9 
     311                                isValidNumber = NO; 
     312                                break; 
     313                        } 
     314                        [enumStr replaceCharactersInRange:prefixR withString:[NSString stringWithFormat:@"%c.", aChar]]; 
     315                } 
     316                if (isValidNumber) { 
     317                        [enumStr appendString:@"e164.arpa"]; 
     318                        telSearch.text = enumStr; 
     319                } 
     320        } else if ([telSearch.text hasSuffix:@".tel"]) { 
    305321                // .tel domain, do nothing 
    306322        } else if ([telSearch.text hasSuffix:@".e164.arpa"]) { 
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us