How to get mailing list contacts from iphone

ABAddressBookRef addressBook = ABAddressBookCreate(); CFArrayRef nameArray = ABAddressBookCopyArrayOfAllPeople (addressBook); m_SourceContactsUserArray = [[NSMutableArray alloc] init]; for (int i = 0; i<CFArrayGetCount(nameArray); i++) { ABRecordRef person = CFArrayGetValueAtIndex(nameArray, i); NSString *personName = (NSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty); [m_SourceContactsUserArray addObject:personName]; } CFRelease(addressBook); CFRelease(nameArray); 
+6
source share
2 answers

Try this code:

 ABAddressBookRef myAddressBook = ABAddressBookCreate(); NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(myAddressBook); for (id record in allPeople) { NSMutableDictionary *newRecord = [[NSMutableDictionary alloc] init]; CFTypeRef bDayProperty = ABRecordCopyValue((ABRecordRef)record, kABPersonBirthdayProperty); if (ABRecordCopyValue((ABRecordRef)record, kABPersonBirthdayProperty)) { NSDate *date=(NSDate*)bDayProperty; [newRecord setObject:date forKey:@"birthDate"]; date=nil; [date release]; } CFRelease(myAddressBook); } 

it will help you.

+16
source

To get CFDateRef for a person’s birthday, use the following:

 CFDateRef date = ABRecordCopyValue(person, kABPersonBirthdayProperty); 
+4
source

Source: https://habr.com/ru/post/913422/


All Articles