问题
Is there a way in the Address Book API to access the current user's record programatically? In other words, if this iPhone belongs to John Smith, to get the contact record that is John Smith (whichever record is marked as Me in Contacts)?
Obviously you can popup the picker and let the user select themselves from their Contacts, but this seems like an unnecessary action for the user to take.
Use case: I have a form in my app and I'd like to pre-populate the form for the user based on their contact info they've already entered. It would be nicer to just display this for them than make them go through all of their contacts and select themselves.
回答1:
There is no access to the users address book card. The reason is that Apple don't want apps to have the ability to see potentially personal information without the user first giving the app access to that information.
I, for one, would not want an app to be able to read my email address, phone number, and home address from my card and do what it pleases with it unless I said it could in the first place.
For that reason, you will have to present the user with the address book picker and allow them to select their address book entry.
来源:https://stackoverflow.com/questions/3642968/how-do-you-access-the-current-users-record-in-address-book