ABAddressBookCopyPeopleWithName() does not correctly match by composite name

Number:rdar://6425729 Date Originated:07-Dec-2008 12:56 AM
Status:Open Resolved:
Product:iPhone SDK Product Version:iPhone SDK for 2.2 OS
Classification:Serious Bug Reproducible:Always
The documentation states that ABAddressBookCopyPeopleWithName() (and, indeed, it makes sense that) it will match records based on composite name, which should be the value returned by ABRecordCopyCompositeName(). Instead, this function ignores properties such as kABPersonPrefixProperty and kABPersonSuffixProperty in the composite name that it matches against for each record in the address book.

Steps to Reproduce:
1. Add two records to the address book of the testing device or simulator with composite names "Mr. Bart Simpson", "Bart Simpson", and "Bart Simpson Jr."
2. Call ABAddressBookCopyPeopleWithName(), giving it a suffix of "Bart Simpson".

Expected Results:
The resulting CFArrayRef should only contain a single ABRecordRef. That is, it should only match the second record with the composite name "Bart Simpson".

Actual Results:
The resulting CFArrayRef contains three ABRecordRefs - one for each record. The ABAddressBookCopyPeopleWithName() function's matching completely ignores the values for properties like prefix and suffix, and uses a non-standard composite name instead of the standard value returned by ABRecordCopyCompositeName() that includes all proper property values.


Not a bug

This is the expected behavior.

This call will return all contacts where the name field CONTAINS the search term, not EQUALS it- e.g. if you search for "Smi" you will get "Mary Smith", "John Smith" and "Mark Smithson".

You can see this in Apple's examples at http://developer.apple.com/library/ios/documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/c/func/ABAddressBookCopyPeopleWithName

If you want to ensure an exact match, you should filter the array it returns further.

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!