访问本机iPhone地址簿数据库并执行添加和删除联系人? [英] Accessing native iPhone addressbook database and performing add and delete contacts?

查看:128
本文介绍了访问本机iPhone地址簿数据库并执行添加和删除联系人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我需要实现应该包含本机地址簿详细信息的地址簿,并且用户应该能够在地址簿中添加和删除它,并且应该在本地iphone地址簿中进行更新。

In my application I need to implement the address book which should contains the native addressbook details, and the user should be able to add and delete from the address book and it should be updated in the native iphone addressbook.

我在某处读到了可以访问iphone原生地址簿数据库的地方。在文档中我也看到addContact和Delete API都暴露在地址簿中。

I read somewhere that the iphone native address book database is accesible. In documentation also I saw that addContact and Delete API's are exposed to addressbook.

任何人都可以告诉我如何访问iphone的本地AddressBook,以及..
如何在通讯录中添加和删除联系人?
任何人都可以为此发布示例代码吗?

Can anyone please tell me how can I access the native AddressBook of the iphone, and.. how to add and delete contacts from the address book? Can anyone post the sample code for this?

推荐答案

你需要使用 ABRecords ABAddressBook 。例如,可以完成添加:

You need to use ABRecords and ABAddressBook. For example, adding can be done:

#import <AddressBook/AddressBook.h>

...

ABRecordRef record = ABPersonCreate();
ABAddressBookRef addressBook = ABAddressBookCreate();

ABRecordSetValue(record, kABPersonFirstNameProperty, CFSTR("Kevin"), NULL);
ABRecordSetValue(record, kABPersonLastNameProperty, CFSTR("Sylvestre"), NULL); 

ABAddressBookAddRecord(addressBook, record, NULL);

ABAddressBookSave(addressBook, NULL);

将AddressBook.Framework添加到项目中非常重要(右键单击'Frameworks'> '添加'>'现有框架')。文档应该足以让你弄清楚如何删除等等。

It is important that you add the AddressBook.Framework to your project (right click on 'Frameworks' > 'Add' > 'Existing Frameworks'). The documentation should give you enough to figure out how to remove, etc.

这篇关于访问本机iPhone地址簿数据库并执行添加和删除联系人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆