开发者

phone number format for iPhone

开发者 https://www.devze.com 2023-03-10 18:02 出处:网络
I have to make calls programmatically in my iPhone app. I have set of numbers in different countries with different formatting - braces, dots, spaces, \"+\" 开发者_JAVA技巧sign.

I have to make calls programmatically in my iPhone app. I have set of numbers in different countries with different formatting - braces, dots, spaces, "+" 开发者_JAVA技巧sign.

Can I simply remove all of this and left only numbers?

for example:

+1-(609) 452-8401 => 16094528401 // usa

+49(0)89.439 => 49089439 // germany

+1-(949)586-1250 => 19495861250 // los angeles, usa

Will it be correct?


try this:-

NSMutableString *str1=[[NSMutableString alloc] initWithString:telephoneString];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@"(" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@")" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@"-" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@" " withString:@""]];
telephoneString = [@"tel://" stringByAppendingString:str1];
[str1 release];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneString]];
0

精彩评论

暂无评论...
验证码 换一张
取 消