Count total contacts from address book - iOS

How can I calculate the total number of contacts from the address book?

+3
source share
3 answers

try it

#import <AddressBook/AddressBook.h>
// ...

- (int)contactsCount {    
    ABAddressBookRef addressBook = ABAddressBookCreate( );
    CFIndex nPeople = ABAddressBookGetPersonCount( addressBook );
    CFRelease( addressBook );
    return (int)nPeople;
}
+6
source

You can try using Erica Sadun ABContactHelper .

At least as a starting point.

There are declarations in ABContactsHelper.h:

+ (int) contactsCount;
+ (int) contactsWithImageCount;
+ (int) contactsWithoutImageCount;
+ (int) numberOfGroups;

I think this is a bit outdated, so you might need to change the code a bit.

0
source
NSArray *people = [book people];
int count = [[book people] count];
-1
source

All Articles