I have some problem while searching the address book. I want to search for phone number using addressbook and compare to check if it matches to some other number.
The plain number to which the addressbook data is to be matched is just like this +358473028403
but when I retrieve the phone number from addressbook record, it comes in formatted like +358.473.028403
. I tried many means of comparing these two string but match always fails. I used this code to filter the characters in the phone number received from the addressbook, but it does not seem to work.
NSCharacterSet *toExclude = [NSCharacterSet characterSetWithCharactersInString:@"/.()- "];
phoneNumber = [[phoneNumber componentsSeparatedByCharactersInSet:toExclude] componentsJoinedByString: @""];
BOOL match = [phoneNumber isEqualToString:@"+358473028403"]
match is still NO
.