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: Rowan <email@hidden>
- Date: Mon, 19 Apr 2004 22:22:22 +0100
On 19 Apr 2004, at 22:05, Louis C. Sacha wrote:
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.
That's a great idea, yes; while Address Book allows custom formatting
to break it down to almost any combination (I'm thinking with fear of
French and other phone systems for which the convention is ## ## ##
##), a few searches by strings of two numbers should do the trick.
cheers!
--Rowan
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.