• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbe Question: Searching Address Book
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbe Question: Searching Address Book


  • Subject: Re: Newbe Question: Searching Address Book
  • From: Nelson Santos <email@hidden>
  • Date: Tue, 2 May 2006 20:44:26 -0700

Ok.  Here is some additional info that may help you out.

There is also the method to help you search for multiple properties at the same time. From the same AB Programming Guide, here is the text:

To combine search elements, use the ABSearchElement class method searchElementForConjunction:children:. These procedures take two arguments:

conjunctionOperator describes how to combine the search elements. It can be kABSearchAnd or kABSearchOr.
children is an NSArray of search elements. The search elements can be a simple elements that specifies only one property, or complex elements that specifies several. This lets you create arbitrarily complex search elements. You cannot combine search elements for groups with search elements for people.



On the other hand, another thing you can do is two separate searches. First, split the entered name into two values using space as the separator. The first search looking for first name, the second search looking for last name. Store the results in 2 separate arrays. Then loop through the first name array and for each one search through the last name array for the same AB entry. If the first and last name equal the entered values, you have a match.


Yet another thing you can do is to first create your own array containing all AB entries with first and last name concatenated properly. Then, write a search algorithm to search through YOUR array for matches to the value entered by the user. Link back to the AB using AB id.

Hope that gives you some ideas.

Nelson



On May 2, 2006, at 8:02 PM, Brad Bumgarner wrote:

Yup, I know that code. In fact I've been able to create a complex query where I can search for first and/or last name. The problem I run into is when I enter the person's first and a space before entering the last name. Since there are no spaces in the db between the first and last names, no entries are found. For now, I'm just going to have to stick with entering the first name. I need to get this moving forward. Once I've got a better handle on things THEN I'll come back to it.

Thanks
Brad Bumgarner, CTA



On May 2, 2006, at 7:40 PM, Nelson Santos wrote:

Hi Brad,

In the link that Andrew provided, you can find the following sample snippet:



ABAddressBook *AB = [ABAddressBook sharedAddressBook];

ABSearchElement *nameIsSmith =
    [ABPerson searchElementForProperty:kABLastNameProperty
                                 label:nil
                                   key:nil
                                 value:@"Smith"
                            comparison:kABEqualCaseInsensitive];

NSArray *peopleFound = [AB recordsMatchingSearchElement:nameIsSmith];



I haven't tried this myself, but it seems pretty straight forward. The first line just fetches a pointer to the address book. The second statement sets up a search criteria object (by last name, value of Smith, case insensitive). The last statement actually executes the search using the criteria returning an array of all the address book entries found.

See if you can work with this and let us know if you are still having trouble.

Nelson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden





_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Newbe Question: Searching Address Book (From: Brad Bumgarner <email@hidden>)
 >Re: Newbe Question: Searching Address Book (From: Andrew Knott <email@hidden>)
 >Re: Newbe Question: Searching Address Book (From: Brad Bumgarner <email@hidden>)
 >Re: Newbe Question: Searching Address Book (From: Nelson Santos <email@hidden>)
 >Re: Newbe Question: Searching Address Book (From: Brad Bumgarner <email@hidden>)

  • Prev by Date: Re: Newbe Question: Searching Address Book
  • Next by Date: Re: show and hide NSWindow
  • Previous by thread: Re: Newbe Question: Searching Address Book
  • Next by thread: Re: Newbe Question: Searching Address Book
  • Index(es):
    • Date
    • Thread