App crashes when contact number that contains a "+" is selected

136 views Asked by At

I have an iPhone app. The user can select a contact. Upon selection another view is opened where the user has to select a phone number.

This works great. However when the phone number contains country code like this +49 ... the app crashes.

-(BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
    ABMutableMultiValueRef multi = ABRecordCopyValue(person, property);
    CFStringRef phone = ABMultiValueCopyValueAtIndex(multi, identifier);

    ///....some code

    [self dismissModalViewControllerAnimated:YES];

    [personViewController.navigationController dismissModalViewControllerAnimated:YES];
    return NO;
}

It stops at this line

CFStringRef phone = ABMultiValueCopyValueAtIndex(multi, identifier);

but there is no error output in the log. Any idea how to fix this?

1

There are 1 answers

0
Totumus Maximus On BEST ANSWER

I don't know where you insert that "+" but you should try to get it replaced by something it can work with.

[yourString stringByReplacingOccurrencesOfString:@"+" withString:@"00"];

If it doesn't help try to follow this link: Address book Phone number (+45) prefix causing crash!