如何获取联系人的创建日期在iOS中使用AddressBook

时间:2015-11-10 11:12:51

标签: ios objective-c abaddressbook abpersonviewcontroller

我必须使用“联系人创建日期”导出iOS设备联系人数据并进行过滤。是否可以使用Objective C?

1 个答案:

答案 0 :(得分:1)

您可以获得任何联系人的创建日期,如下所示

ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);

ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, err);
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
ABRecordRef person = CFArrayGetValueAtIndex( allPeople, 0 );

NSDate* createDate = (__bridge NSDate*) ABRecordCopyValue( person, kABPersonCreationDateProperty);
NSDate* updateDate = (__bridge NSDate*) ABRecordCopyValue( person, kABPersonModificationDateProperty);