gpt4 book ai didi

iphone - 如何从 iPhone 获取生日联系人列表

转载 作者:行者123 更新时间:2023-12-03 18:41:08 26 4
gpt4 key购买 nike

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);

最佳答案

试试这个代码:

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);
}

它会对你有帮助。

关于iphone - 如何从 iPhone 获取生日联系人列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10190988/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com