Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:32:48+00:00 2026-05-20T22:32:48+00:00

I wish to search in the iphone AddressBook through my app using the number

  • 0

I wish to search in the iphone AddressBook through my app using the number as the key and then retrieve the image associated to that contact and display it on the UIImageView.

I tried using ABAddressBook framework but was clueless to proceed.

Can anyone please suggest me the solutions or any alternative path that I can follow. Any code snippet would also be of great help!!

Any form of help would be highly appreciable.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:32:48+00:00Added an answer on May 20, 2026 at 10:32 pm

    The AB framework can be a real pain at times. But it breaks down to a series of pretty simple operations. First, you have to create an ABAddressBook instance:

    ABAddressBookRef addressbook = ABAddressBookCreate();
    

    Then you’ll want to make a copy of the array of all people in the address book, and step through them looking for the data you want:

    CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressbook);
    CFIndex numPeople = ABAddressBookGetPersonCount(addressbook);
    for (int i=0; i < numPeople; i++) { 
    

    Inside your loop, you’ll probably want to get a reference to the individual person:

    ABRecordRef person = CFArrayGetValueAtIndex(allPeople, i);
    

    Then you want to compare the number you have (lets call that inNumber) to every phone number associated with that particular person. To do that, you first need a list of all the person’s phone numbers:

    ABMutableMultiValueRef phonelist = ABRecordCopyValue(person, kABPersonPhoneProperty);
    

    Then, of course, you’ll need to have an inner loop that loops over each of the individual person’s phone numbers:

    CFIndex numPhones = ABMultiValueGetCount(phones);
    for (int j=0; j < numPhones; j++) {
    

    Since the phone numbers have both numbers and labels associated with them, you’ll need to extract the actual phone number string as an NSString:

    CFTypeRef ABphone = ABMultiValueCopyValueAtIndex(phoneList, j);
    NSString *personPhone = (NSString *)ABphone;
    CFRelease(ABphone);
    

    Now you can finally compare numbers! Do so with the standard NSString comparison methods, but remember that you need to worry about formatting, etc.

    Once you find the person who has a phone number matching inNumber, you’ll want the extract that person’s image into a UIImage:

        CFDataRef imageData = ABPersonCopyImageData(person);
        UIImage *image = [UIImage imageWithData:(NSData *)imageData];
        CFRelease(imageData);
    

    When it comes time to exit, you’ll need to clean up memory. A general rule of thumb for the AB framework is that anything with Get in the function name you don’t need to release, and anything with Copy or Create, you do need to release. So, in this case you’ll need to CFRelease() phonelist, allPeople, and addressbook, but not numPeople, person, or numPhones.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to create a very simple web app that simply displays an Image(s)
I often wish to search for variables that are simply called 'c' or 'count'.
I wish to return only the number of google search results for a particular
I wish to create a custom search webpart using visual studio 2010 using c#.
I have a search method that takes a list of ID's and I wish
Using ditto I have created a product catalogue. I now wish to add search
I have a directory of ~100 plaintext files that I wish to search for
Using iPhone SDK 3.0, I wish to allow text entry with (optional) completion options
I wish to make so when you search e.g A then every full_name with
I wish to do a search and replace in a string. It searches for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.