0

What's wrong with this code :

NSMutableArray* contactArray = [[NSMutableArray alloc] init];

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook); // Over here it returns zero count.
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
for (int i = 0 ; i < nPeople; i++) {
    NSMutableDictionary* dicContact = [[[NSMutableDictionary alloc] init] autorelease];
    ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
}

It works perfectly in Simulator but not able to get the list of contacts in Device. Where I am missing out to get the contacts from device ?

Console Output : (Simulator)

Printing description of contactArray:

    <__NSArrayM 0xa13e810>(
{
    City = "";
    State = "";
    Street = "";
    ZIP = "";
    email = "kate-bell@mac.com";
    firstname = Kate;
    lastname = Bell;
    organization = "Creative Consulting";
    telephone = "(555) 564-8583";
}
)
Ajay Sharma
  • 4,509
  • 3
  • 32
  • 59
  • 1
    which iOS you have in your device? Because iOS 6 is not allowing user to access contacts without user's permission.I have read somewhere, it will work properly on simulator but will not work on device. – spaleja Nov 19 '12 at 06:21
  • +1 from me . Yes you are right... I got to see that. BTW thanks for your assistance. – Ajay Sharma Nov 19 '12 at 06:36
  • hi i am printing ref in nslog then the output is how to get all this information name,telephone,email. thanks in advance – MANCHIKANTI KRISHNAKISHORE Jan 08 '14 at 08:45

0 Answers0