ABAddressBook 学习笔记

一 . 线程安全

1.Recordobjectscannotbepassedacrossthreadssafely.Instead,youshouldpassthe corresponding record identifier

2. InstancesofABAddressBookRefcannotbeusedbymultiplethreads.Eachthreadmustmake its own instance.



二. 
1. 变化通知 (不同app或不同线程引起, 本线程不会引起 ):

Use the function ABAddressBookRegisterExternalChangeCallback to register a function of the prototype ABExternalChangeCallback. You may register multiple change callbacks by calling ABAddressBookRegisterExternalChangeCallback multiple times with different callbacks or contexts. You can also unregister the function using ABAddressBookUnregisterExternalChangeCallback.

When you receive a change callback, there are two things you can do: If you have no unsaved changes, your code should simply revert your address book to get the most up-to-date data. If you have unsaved changes, you may not want to revert and lose those changes. If this is the case you should save, and the Address Book database will do its best to merge your changes with the external changes. However, you should be prepared to take other appropriate action if the changes cannot be merged and the save fails.

2. person \ group

application can use groups to allow the user to perform an action for several contacts in their address book at the same time.


Group records have only one property,  kABGroupNameProperty,  which is the name of the group. To get all the people in a group, use the function  ABGroupCopyArrayOfAllMembers  or  ABGroupCopyArrayOfAllMembersWithSortOrdering,  which return a  CFArrayRef  of  ABRecordRef  objects.

3. vc

The Address Book UI framework provides four controllers:

ABPeoplePickerNavigationController prompts the user to select a person record from their address book.

ABPersonViewController displays a person record to the user and optionally allows editing. ABNewPersonViewController prompts the user create a new person record.

ABUnknownPersonViewController prompts the user to complete a partial person record, optionally allows them to add it to the address book.

可以定制界面显示内容: set displayedProperties to the array of properties you want displayed.

4. 数据库

To accomplish other kinds of searches, use the function ABAddressBookCopyArrayOfAllPeople and then filter the results using the NSArray method filteredArrayUsingPredicate:.

To sort an array of people, use the function  CFArraySortValues  with the function  ABPersonComparePeopleByName  as the comparator and a context of the type  ABPersonSortOrdering.


转载于:https://my.oschina.net/dake/blog/196701

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值