How to get birthday list contacts from iphone
addressbook, iphone
Solution
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.
Problem
``` 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); ```