小编N. *_*jay的帖子

使用ABMultiValueCopyValueAtIndex时,如何删除所有特殊字符的NSString?

当我使用ABpeoplePickerNavigationController时,当调用下面的委托时,我试图执行以下操作:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
    if(property == kABPersonPhoneProperty || property == kABPersonEmailProperty)
    {
        NSString *name = (__bridge NSString *)ABRecordCopyCompositeName(person);
        ABMutableMultiValueRef multi = (ABMultiValueRef)ABRecordCopyValue(person, property);
        NSString *number = (__bridge NSString*)ABMultiValueCopyValueAtIndex(multi, identifier);
        if(![VZMUtils validateEmail:number])
            number = [VZMUtils formatIdentificationNumber:number];
        number = [number stringByReplacingOccurrencesOfString:@"." withString:@""];
        ALog(@"number %@ and name %@",number,name);
        [self.popoverDelegate setDataWithName:name andDetail:number];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid type selected." message:@"Please select either a phone number or email address to add as a recipient" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, …
Run Code Online (Sandbox Code Playgroud)

objective-c abaddressbook ios ios7 xcode5

2
推荐指数
1
解决办法
815
查看次数

标签 统计

abaddressbook ×1

ios ×1

ios7 ×1

objective-c ×1

xcode5 ×1