0

I have implemented the code to get contact list form address book. For that I have used this code

ABAddressBookRef addressBook = ABAddressBookCreate( );
CFArrayRef allSources = ABAddressBookCopyArrayOfAllPeople( addressBook );
CFIndex nPeople = ABAddressBookGetPersonCount( addressBook );

and when this code is executing then my app is crashing and in crash report I got that

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Crashed Thread:  5

And I am testing on iPhone 3GS with ios 6.0.

So how I fix this bug?

ios
  • 552
  • 5
  • 22
  • When I read the title, I thought OP was aaking how *not* to create an address book... –  Aug 18 '12 at 06:24

2 Answers2

1

Thanks for support and I got the solution. Solution of my issue is

ABAddressBookRef addressBook = ABAddressBookCreate();

This is deprecated in ios 6.0.

ios
  • 552
  • 5
  • 22
0

Use this code ,it will give you the objects list.

ABAddressBookRef addressBook = ABAddressBookCreate(); 
ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
NSArray *persons = (NSArray *)(ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonSortByFirstName));
Sanoj Kashyap
  • 5,020
  • 4
  • 49
  • 75
  • I am getting nil value in address book while i have 152 contacts in address book. – ios Aug 17 '12 at 08:08
  • i am getting as i have one contact.Check for other property. – Sanoj Kashyap Aug 17 '12 at 08:53
  • Please check this [link](http://stackoverflow.com/questions/11985317/retrieve-selected-group-from-native-contact-application/11986219#11986219), i have given one ans try that.It may help you. – Sanoj Kashyap Aug 17 '12 at 09:01