ios
ios

Reputation: 552

Not creating address book object

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?

Upvotes: 0

Views: 898

Answers (2)

ios
ios

Reputation: 552

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

ABAddressBookRef addressBook = ABAddressBookCreate();

This is deprecated in ios 6.0.

Upvotes: 1

Sanoj Kashyap
Sanoj Kashyap

Reputation: 5060

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

ABAddressBookRef addressBook = ABAddressBookCreate(); 
ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
NSArray *persons = (NSArray *)(ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonSortByFirstName));

Upvotes: 0

Related Questions