Filtering out email addresses from ABPeoplePickerNavigationController
Asked Answered
I

4

7

I'm using ABPeoplePicker to show a list of contacts.

I'd like to filter this list of contacts to only show the contacts that have email addresses. How would I do so?

Iowa answered 28/3, 2011 at 17:7 Comment(0)
F
3

I needed it, so I started working on something like that. Check out https://github.com/stuffmc/MCFilteredPeoplePickerNavigationController

Flock answered 30/12, 2012 at 0:47 Comment(4)
You put a "How to use" but you show nothing about actually filtering.Dubonnet
It's for the user to filter. But if you look at the code (specifically at loadContacts you should find it — check github.com/stuffmc/MCFilteredPeoplePickerNavigationController/…Flock
Ah, I see. I was looking for something where I (as the dev) could filter the list to only show contacts with emails :DDubonnet
Turns out that's also something I do, if you look here you'll see I only take those contacts having a kABPersonAddressProperty (an address).Flock
P
2

here is the good blog tutorial for extracting address book values,

http://blog.slaunchaman.com/2009/01/21/cocoa-touch-tutorial-extract-address-book-address-values-on-iphone-os/

try with below:

ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
    [peoplePicker setPeoplePickerDelegate:self];
    [peoplePicker setDisplayedProperties:[NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonEmailProperty]]];
Pricefixing answered 28/3, 2011 at 17:19 Comment(1)
This code doesn´t answer the question. This displays all the contacts, and when you select it only shows email (or "No email addresses" when the contact is without email).Theis
B
0

ABContactHelper is a greater wrapper for the Addressbook and has some methods for filtering contacts based on various things.

https://github.com/erica/ABContactHelper

Blight answered 29/3, 2011 at 17:15 Comment(0)
A
0

I'm trying to do a similar thing. I've gotten an instance of ABAddressBook, removed the entries I don't want, then set picker.addressBook = filteredBook. It...KINDA works. The list seems to be filtered, but entries are duplicated like it expects the full list to be there and it just copies existing entries until it has the expected count, or something.

Ameliaamelie answered 31/12, 2013 at 6:14 Comment(2)
Did you find a reason / resolution?Wrapping
@Wrapping I did not, I'm afraid. I haven't really done much with it since.Ameliaamelie

© 2022 - 2024 — McMap. All rights reserved.