AddressBook - how to search for absence of value?
AddressBook - how to search for absence of value?
- Subject: AddressBook - how to search for absence of value?
- From: Jim Correia <email@hidden>
- Date: Tue, 15 Oct 2002 16:59:06 -0400
[Pardon the question on the Cocoa list. As far as I know there isn't a
specific list for the AddressBook.]
I'd like to query the Address Book for the absence of a term.
Specifically I want to find all values whose first name is empty, and
whose last name starts with a specific value. The following code
doesn't work. When I log all the values from the address book it
doesn't log any value for the first name of the entry that doesn't have
one.
What am I doing wrong?
Thanks,
Jim
#import <AddressBook/AddressBook.h>
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ABSearchElement *elem1 = [ABPerson searchElementForProperty:
kABFirstNameProperty label: nil key: nil value: @"" comparison:
kABEqual];
ABSearchElement *elem2 = [ABPerson searchElementForProperty:
kABLastNameProperty label: nil key: nil value: @"z" comparison:
kABPrefixMatchCaseInsensitive];
NSArray *elements = [NSArray arrayWithObjects: elem1, elem2, nil];
ABSearchElement *conjunction = [ABSearchElement
searchElementForConjunction: kABSearchAnd children: elements];
NSArray *matches = [[ABAddressBook sharedAddressBook]
recordsMatchingSearchElement: conjunction];
NSLog(@"%@", matches);
NSLog(@"%@", [[ABAddressBook sharedAddressBook] people]);
[pool release];
return 0;
}
_______________________________________________
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.