在 iPhone SDK 中创建一个空的 ABAddressBook?
我可以创建一个不从地址簿读取数据的 ABAddressBook 吗?即一开始它是空的,这样我就可以放入从互联网上获取的我自己的联系人。
如您所知,该函数
ABAddressBookRef ab = ABAddressBookCreate();
为我提供内置地址簿中的数据。这不是我想要的,但如果您知道我的问题的解决方案,请告诉我。
Can I create an ABAddressBook which does not read data from my address book. i.e. it's empty to start with so that I can put in my own contacts fetched from the internet.
As you may know the function
ABAddressBookRef ab = ABAddressBookCreate();
gives me data from the built in addressbook. This is not what I want but if you know a solution to my problem please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为不可能有 ABAddressBook 的空实例。该文档只是关于获取一个ABAddressBook来填充iPhone的地址簿。
I don't think it is possible to have an empty instance of ABAddressBook. The documentation is only about getting an ABAddressBook filled with the address book of the iPhone.
您可以尝试创建一个用联系人填充的数组(或可变数组),并将该数组放入
UITableView
中。You could try making an array (or mutablearray) that you fill with the contacts and put the array inside a
UITableView
.我一直在开发一个“私人联系人”应用程序,该应用程序将联系人存储在普通地址簿之外,我可以确认这确实是可能的,只要通过一点点操作即可。但是,使用 ABAddressBookRef 变量根本没有帮助。您需要的是 ABRecordRef 的 NSMutableArray,这就是 iOS 存储其联系人的方式。
I've been working on a "private contacts" app which stores contacts off of the normal address book and I can confirm that this is indeed possible, if only through a little manipulation. Using the ABAddressBookRef variable, however, won't help you at all. What you need is a NSMutableArray of ABRecordRef's, which is how iOS stores its contacts.
您可以尝试使用 memset/calloc 将 ABAddressBookRef 清零,看看是否会给出所需的结果。
You could try to zero out ABAddressBookRef with a memset/calloc and see if that gives you the desired result.