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 8378137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:51:29+00:00 2026-06-09T15:51:29+00:00

I want to show only those contacts having address field.i am using this code..

  • 0

I want to show only those contacts having address field.i am using this code.. please help..

- (ABAddressBookRef)getValidAddress{

    ABAddressBookRef allPeople = ABAddressBookCreate();
    ABAddressBookRef contactsWithAddress = ABAddressBookCreate();
    CFArrayRef allContacts = ABAddressBookCopyArrayOfAllPeople(allPeople);
    CFIndex numberOfContacts = ABAddressBookGetPersonCount(allPeople);
    CFErrorRef  anError = NULL; 

    for(int i=0; i<numberOfContacts;i++){
        ABRecordRef aPerson = CFArrayGetValueAtIndex(allContacts, i);
        ABMultiValueRef AddressProperty = ABRecordCopyValue(aPerson, kABPersonAddressProperty);
        if(ABMultiValueGetCount(AddressProperty)>0){
            NSLog(@"this dude has address, he's on the list");
            //ABAddressBookAddRecord(contactsWithEmail, aPerson, &anError);
        }
        else{
            NSLog(@"this guy has no address, removing them from the addressBook");
            ABAddressBookRemoveRecord(contactsWithAddress, aPerson, &anError);
        }

    }

    return contactsWithAddress;
}


- (void)searchBarBookmarkButtonClicked:(UISearchBar *)searchBar
{

    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];

    ABAddressBookRef test = [self getValidAddress];
    [picker setAddressBook:test];

    NSArray* emailProp = [NSArray arrayWithObjects:
    [NSNumber numberWithInt:kABPersonPhoneProperty], 
    [NSNumber numberWithInt:kABPersonEmailProperty],
    [NSNumber numberWithInt:kABPersonBirthdayProperty],
    [NSNumber numberWithInt:kABPersonAddressProperty],
    nil];;
    picker.displayedProperties = emailProp;

    picker.peoplePickerDelegate = self;
    [self presentModalViewController:picker animated:YES];
    //[parentController presentModalViewController:picker animated:YES];

    [picker release];

}

Now its showing contact in picker who have address but now my output is :

TEST1 44-541541-52 D-551, new york, TEST2 54-965684-85 j.V
street India, TEST3 95-95684-956 NIL, TEST3 20-95684-956 NIL,

now i am getting this output:

TEST1 TEST2 TEST2 TEST2

Please Help…
its showing duplicate..

  • 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-06-09T15:51:30+00:00Added an answer on June 9, 2026 at 3:51 pm

    I am afraid you are out of luck. ABPeoplePickerController is a quite limited class.

    You will have to roll your own people picker controller and populate it with all records from the address book which you have iterated through and filtered before.

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

Sidebar

Related Questions

I want to show only desired number of elements in list when I click
I have a bunch or markers, and I want to show only the area
i have DataTimePicker control in my form. i want to show only hh:mm how
I want to show up only words with minimum 4 Characters, actually I can
I want to only show posts on a wordpress page that belong to logged
I want my JTextArea to show only the caret. I've setted my JTextArea to
I only want to show my title attribute in some cases. I don't want
I want that screenCheck function show run only after Validation of #contact_email . But
I want to show popup box on a right-click at JTree node only, not
Background: I want to show the time and date uptill only 1 week. After

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.