gpt4 book ai didi

ios - 从地址簿问题中获取号码

转载 作者:行者123 更新时间:2023-11-29 04:01:54 24 4
gpt4 key购买 nike

我为此目的使用以下代码

 ABMultiValueRef phones = (ABMultiValueRef)ABRecordCopyValue(ref, kABPersonPhoneProperty);
NSString* mobile=@"";
NSString* mobileLabel;
for (int i=0; i < ABMultiValueGetCount(phones); i++) {
//NSString *phone = (NSString *)ABMultiValueCopyValueAtIndex(phones, i);
//NSLog(@"%@", phone);
mobileLabel = (NSString*)ABMultiValueCopyLabelAtIndex(phones, i);
if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMobileLabel]) {
NSLog(@"mobile:");
} else if ([mobileLabel isEqualToString:(NSString*)kABPersonPhoneIPhoneLabel]) {
NSLog(@"iphone:");
} else if ([mobileLabel isEqualToString:(NSString*)kABPersonPhonePagerLabel]) {
NSLog(@"pager:");
}
[mobile release];
mobile = (NSString*)ABMultiValueCopyValueAtIndex(phones, i);
NSLog(@"%@", mobile);
[_Phonearray addObject:mobile];
}

现在我的问题是_phonearray的nslog是这样的

_

Phonearray(
"(658) 932-6593",
"(654) 498-9878"
)

但我想要这样

_Phonearray(
"6589326593",
"6544989878"
)

那么我应该在代码中做什么:?

最佳答案

那么,您想从移动设备中删除所有非数字字符吗?我在这里找到了一个方法:

Removing all non wanted characters using the NSCharacterSet - Stack Overflow

NSCharacterSet* charactersToRemove = [[NSCharacterSet decimalDigitCharacterSet] invertedSet] ;
mobile = [[mobile componentsSeparatedByCharactersInSet:charactersToRemove] componentsJoinedByString:@""] ;

关于ios - 从地址簿问题中获取号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15744641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com