openURL打电话

  1. 通过正则表达式
  2. -(NSString *) formatIdentificationNumber:(NSString *)string

    {

        NSCharacterSet * invalidNumberSet = [NSCharacterSet characterSetWithCharactersInString:@"\n_!@#$%^&*()[]{}'\".,<>:;|\\/?+=\t~` "];

        

        NSString  * result  = @"";

        NSScanner * scanner = [NSScanner scannerWithString:string];

        NSString  * scannerResult;

        

        [scanner setCharactersToBeSkipped:nil];

        

        while (![scanner isAtEnd])

        {

            if([scanner scanUpToCharactersFromSet:invalidNumberSet intoString:&scannerResult])

            {

                result = [result stringByAppendingString:scannerResult];

            }

            else

            {

                if(![scanner isAtEnd])

                {

                    [scanner setScanLocation:[scanner scanLocation]+1];

                }

            }

        }

        

        return result;

    }


    - (NSString *)makeCall:(NSString *)number

    {

        NSString *txt = number;

        NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"-+() *#"];

        txt = [[txt componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @""];

        txt = [NSString stringWithFormat:@"tel://%@", txt];

        return txt;

    }

找了好久这个代码!终于找到了!

哈哈

你可能感兴趣的:(openURL打电话)