Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to get a new created person ID?

Posted on 2013-02-07
4
Medium Priority
?
716 Views
Last Modified: 2013-02-13
Hello,
I'm very new to the iOS programming, so please excuse me if my question is too dumb.
I need to create a contact in the address book, and as soon it's created, I need to know the ID of the new created contact.

Basically I call ABRecordRef person = ABPersonCreate(); then populate the properties, etc.
Then I call ABRecordGetRecordID( person ) to get the contact ID. But it always returns -1 (kABRecordInvalidID). I tried to save the AB and obtain it again, etc. no luck.
I see the new contact has actually been added to the contact list, but how can I obtain it's ID??

The only solution now I could imagine is to calculate the hash of all the properties, and then reopen the AB and search for a contact with the hash value.

Please help!
0
Comment
Question by:zc2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 2000 total points
ID: 38867505
>Basically I call ABRecordRef person = ABPersonCreate(); then populate the properties, etc.

You didn't mention ABAddressBookAddRecord and ABAddressBookSave. I think, this is the error.
0
 
LVL 19

Author Comment

by:zc2
ID: 38886181
Thank you very much for the answer.
I do call ABAddressBookSave(), but I'm not sure about the ABAddressBookAddRecord() function.
At what point should I call it? Right after ABAddressBookSave() ? Before I call ABRecordSetValue() to write the properties or after that?
0
 
LVL 19

Author Closing Comment

by:zc2
ID: 38886254
Finally I've made that work properly. Was good to know it's possible after all, thank you!
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 38887886
You are welcome
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

     Intro      In this article, I will show you how to parse a JSON in Swift using an open source library called SwiftyJSON (https://github.com/SwiftyJSON/SwiftyJSON). If you haven't heard of a JSON before, it stands for JavaScript Object Notation…
Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question