我想获取联系人信息中保存有生日的联系人,并检索这些联系人的详细信息,如电话号码、电子邮件、生日等。
这是我尝试过的:
ABAddressBookRef myAddressBook = ABAddressBookCreate();
NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(myAddressBook);
contactList = [[NSMutableArray alloc]init];
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);
}
任何的想法?