Re: Attempting to match phone numbers in the Address Book
Re: Attempting to match phone numbers in the Address Book
- Subject: Re: Attempting to match phone numbers in the Address Book
- From: "Louis C. Sacha" <email@hidden>
- Date: Mon, 19 Apr 2004 14:05:48 -0700
Hello...
Maybe you could use a compound search using each part of the number
to quickly get a list of possible matches?
In other words to search for (123)456-7890, use kABSearchAnd to make
a compound search from three searches using kABContainsSubstring for
123, 456, and 7890 within kABPhoneProperty.
This should create a short list of results that you could go through
with a more comprehensive algorithm. (For example, using NSStrings to
strip out any characters that are not digits and then comparing the
strings, etc...)
Hope that helps,
Louis
I wasn't sure which list to post this to, so as always the fallback
is cocoa-dev :)
I've added a simple Caller ID function to an app which uses the
address book framework to check for known numbers; however, while
this works, it has a couple of problems. I'm using an
ABSearchElement equal to [ABPerson
searchElementForProperty:kABPhoneProperty label:nil key:nil
value:aString comparison:kABEqual], and while this seems to work for
numbers entered via a phone, it doesn't match numbers entered in the
Address Book.
I've tracked this down to the "Automatically format phone numbers"
option in Address Book. Numbers entered via a phone and then
transferred via iSync seem to be stored as 123456789, and displayed
as (123) 456 789, whereas numbers entered directly into Address Book
seem to be stored as (123) 456 789. In the former case, passing
123456789 to the ABSearchElement finds a match; in the latter case,
no match is found.
So passing a normal string to the value: option doesn't match unless
you pass the formatted number, if what I'm seeing is correct.
What's the recommended method for matching Address Book formatting?
Should I grab ABPhoneFormat-PhoneFormatter from
com.apple.AddressBook.plist and pre-format my numbers before trying
to match them?
Interestingly enough, if the number formatting preference is
changed, the Address Book displayed value changes; however,
searching by the new string matches nothing, while searching by the
old string provides a match. Is anything possible in these
situations?
Cheers,
--Rowan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.