1

I am having some trouble with this.. I see that we are supposed to be using the property:

predicateForSelectionOfProperty

for determining which properties get 'selected', and I'm actually kind of bummed for there not being a

predicateForEnablingProperty

because I only want phone numbers, for my use case.

That said, nothing I use for predicateForSelectionOfProperty seems to do what I want. What I want is, when I select a contact's phone number, it should call the delegate callback.. but instead, right now, it is calling them!

Maybe I'm just completely missing something, because I would actually rather just have a list of my contacts, with phone numbers, and only show the phone numbers.. maybe I'm not even heading in the right direction with this.

Thanks for any help you can offer!

JP.
  • 544
  • 5
  • 20

1 Answers1

1
  1. If you don't want it to call the number, you should:

    • specify the peoplePickerDelegate; and

    • implement peoplePickerNavigationController:didSelectPerson:property:identifier:

    • don't specify a predicateForSelectionOfProperty (or if you do, make sure it returns true, e.g. NSPredicate(value: true))

  2. Obviously, if you don't even want it to show you unrelated information about contacts, specify the displayedProperties array, e.g.

    controller.displayedProperties = [NSNumber(int: kABPersonPhoneProperty)]
    
  3. Alternatively, if you wanted to customize this UI further, you could just use the AddressBook.framework to extract the phone numbers from the address book and present whatever UI you want.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • 1. I did implement peoplePickerNavigationController:didSelectPerson:property:identifier and it never gets called. 2. Thanks, that should be very helpful (wasn't so obvious to me, but it might have been once I got the other stuff working) 3. I might have to go this route (eventually, if not now). We'll see. So, #1 isn't working for me.. basically, I DO have the delegate set, but the method NEVER gets called. =/ – JP. Mar 15 '15 at 17:09
  • 1
    Are you sure you're setting the `peoplePickerDelegate` and not the `delegate`? Also, are you sure that the method signature is exactly correct (because if you mistype the method name, it won't warn you, as this method is optional). – Rob Mar 15 '15 at 19:32
  • Interestingly, I was accidentally calling .delegate instead of .peoplePickerDelegate, but I've changed it now, and still the method: - (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier Is NOT getting called. In the past there was a 'shouldContinueAfterSelectingPerson:property' but it's been deprecated :( I'll dig into this more. Thanks for your help so far.. – JP. Mar 17 '15 at 01:52
  • It turns out I still had a .predicateForSelectionOfProperty set from me previously trying to solve the issue :P Removing that fixed it! Thanks again! – JP. Mar 17 '15 at 01:55
  • I have the problem but these solutions not working for me. see http://stackoverflow.com/questions/39700966/avoid-cncontactpickerviewcontroller-to-show-emails – Husein Behboudi Rad Sep 26 '16 at 11:39