0

I have to export iOS device contact data and filter using "contact creation date" .Is it possible to do using Objective C ?

Subodh Kumar
  • 229
  • 3
  • 8

1 Answers1

1

You can get creation date of any contact as below,

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);
Avaan
  • 4,709
  • 1
  • 10
  • 13
  • Will "creation date" kABPersonCreationDateProperty" property reflect in exported CSV files? Because i have to filter after export contact in CSV using some query. – Subodh Kumar Nov 10 '15 at 11:47
  • Not sure it will be part of exported cvs file or not, but you can read all the contacts data into "NSMutableString" in cvs format and then write into the file as mentioned in http://stackoverflow.com/questions/12659654/xcode-create-csv-spreadsheet-file. – Avaan Nov 10 '15 at 12:39
  • Thanks Avaan for your help. – Subodh Kumar Nov 10 '15 at 12:47
  • can you give vote if it is useful... – Avaan Nov 10 '15 at 13:00