Tommy Nicholas
Tommy Nicholas

Reputation: 1173

Get the ABRecordID from newly added Address Book Object ios

I have an application that adds Contacts to the Address Book in iOS, and all I need is to store the ABRecordID or ABRecordref as soon as I save the contact.

ABAddressBookAddRecord(addressbook, newPerson, &theerror);
ABAddressBookSave(addressbook, &theerror);

This question is extremely similar, but I don't understand the answer: ABRecordID for a record in addressbook(unique id for inserted record in addressbook)

How do you know the

ABRecordID ABRecordGetRecordID (
ABRecordRef newPerson
);

Some help here would be fantastic - thanks!

Upvotes: 8

Views: 4672

Answers (1)

omz
omz

Reputation: 53551

Simply call ABRecordGetRecordID(newPerson) after you've saved the address book (before that, there won't be a valid ID).

//...
ABRecordID recordID = ABRecordGetRecordID(newPerson);

An ABRecordID is the same as an int_32 (a 32-bit integer).

Upvotes: 19

Related Questions