Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在将电话号码从 iPhone 通讯簿复制到文本字段。在文本字段中,它显示为 1 (234) 567-8901。我想将其格式化为 12345678901。有 什么帮助吗?
您可以使用stringByReplacingOccurrencesOfString: withString:删除不需要的字符,@"("例如@""
stringByReplacingOccurrencesOfString: withString:
@"("
@""
编辑:更好的解决方案。
NSCharacterSet *charSet =[NSCharacterSet characterSetWithCharactersInString:@"()- "]; cleanedPhoneNumber = [phoneNumberString stringByTrimmingCharactersInSet:charSet];