2

how I can read from my addressbook all contacts in different source type in email ? Now I able to read only local contacts with all group, but in my iPhone if go into Contacts find more different group (All contacts, All from Mac, iCloud, All Yahoo, All Hotmail.. ).

My question is: Source yahoo have this contacts: ..... Source Hotmail have this contacts: ..... How it made ?

Placebo
  • 31
  • 6
  • this is my addressbook structure: `AllContacts` **From Mac**: `All (from Mac)` - `University`. **iCloud**: `All (iCloud)` - `Work` **Placebo Yahoo**: `All (Placebo Yahoo)` – Placebo Apr 20 '12 at 16:37

1 Answers1

0

Use ABAddressBookCopyArrayOfAllGroupsInSource to get an array of the groups. Then, with ABGroupCopyArrayOfAllMembers you can get all the members belonging to that group.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
  • I have already tried but in source i don't have group, therefore the `ABAddressBookCopyArrayOfAllGroupsInSource` return empty – Placebo Apr 20 '12 at 16:32
  • `ABAddressBookCopyArrayOfAllGroupsInSource` is supposed to give you all the groups, which you can iterate. You get sources with `ABAddressBookGetSourceWithRecordID`, which you can use with an enum Apple provides. More info here: http://stackoverflow.com/questions/3108413/abaddressbook-absource-and-absourcetype – Léo Natan Apr 20 '12 at 16:43
  • Ok, but if I want only contacts from source **Placebo Yahoo** that don't have group, how I make? – Placebo Apr 20 '12 at 16:54
  • Placebo Yahoo is the group. You have to find the right source which contains that group. My guess is kABSourceTypeCardDAV. Try iterating on the groups of kABSourceTypeCardDAV and see if Placebo Yahoo is there. – Léo Natan Apr 20 '12 at 16:58
  • I find only two group, **Work** and **University** for two different source. – Placebo Apr 20 '12 at 17:37
  • All sources in addressBook `ABAddressBookCopyArrayOfAllSources(addressBook);` I have 6 sources but only 2 group. – Placebo Apr 20 '12 at 17:51