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]];
精彩评论