转换iPhone电话号码格式以获得"可拨号"字符串

Tom*_*myG 0 iphone xcode objective-c nsstring ios

我正在构建一个iphone应用程序,它从地址簿中读取一个电话号码并拨打它(当然还有其他一些东西...... :)).当我从AB加载电话号码时,它们采用以下格式:"1(111)111-1111"使用时不能"拨号":

fullNumber = [NSString stringWithFormat:@"%@%@", @"tel:", phoneNum];
Run Code Online (Sandbox Code Playgroud)

为什么会这样?什么是最好的方法来解决这个问题?我怎么能将电话号码转换成一串数字(没有空格或" - ")?

谢谢.

jon*_*oll 18

这将删除所有非数字字符:

phoneNumDecimalsOnly = [[phoneNum componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""];
Run Code Online (Sandbox Code Playgroud)