I want reference of my address book in one of iPhone application. I have used below code. But its showing [people count] = 0.
I have 3-4 contacts on my addressbook application still [people count] returns zero.
Is anything more, I am missing here?
Code is:
ABAddressBookRef addressBook = ABAddressBookCreate();
NSMutableArray *people = [[[(NSArray*)ABAddressBookCopyArrayOfAllPeople(addressBook) autorelease] mutableCopy]autorelease];
[people sortUsingFunction:(int (*)(id,id,void*)) ABPersonComparePeopleByName context:(void*)ABPersonGetSortOrdering()];
NSLog(@"count..%i",[people count]);
for(int i = 0 ; i < [people count]; i++){
ABRecordRef person = [people objectAtIndex:i];
//get phone no fill phone no into array
ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonPhoneProperty);
if(multi!=NULL && ABMultiValueGetCount(multi)>0) {
NSLog(@"in value..");
}
else {
NSLog(@"no value");
}
}
Thank You