IOS Address Book Basics
After iOS 6, the app needs to be authorized to access the address book once, even if it is uninstalled and then installed, no further authorization is required;
Two frameworks are required for the development of Address Book applications:
1. ABAddressBook is mainly used to provide APIs for accessing the records and attributes in the address book. You need to build your own UI.
2. The ABAddressBookUI framework provides us with four view controllers and corresponding delegation protocols. They have provided the UI interface.
The class before the common class "()" in the ABAddressBook framework is the class in the Foundation, and the class in the () is the class in the Core Foundation framework.
ABAddressBook (ABAddressBookRef) encapsulate the access address book interface;
ABPerson (ABPersonRef) encapsulates the address book personal information data, which is a record of the database;
ABGroup (ABGroupRef) encapsulates Address Book information data. A group contains information of multiple people. A person's information can belong to multiple groups;
ABRecord (ABRecordRef) encapsulates a record in the database, which is composed of attributes;
View Controller in ABAddressBookUI framework
ABPeoplePickerNavigationController selects the contact navigation controller from the database. The delegate protocol is ABPeoplePickerNavigationControllerDelegate.
ABPersonViewController views and edits the information of a single contact. The delegate protocol is ABPersonViewControllerDelegate.
ABNewPersonViewController creates new contact information. The delegate protocol is ABNewPersonViewControllerDelegate.
ABUnknowPersonViewController displays part of the record information, which can be used to create new contacts or add existing contacts. The corresponding delegate protocol is ABUnknowPwesonViewControllerDelegate.
When using ABAddressBook, we use the Core Foundation framework. The Core Foundation (c) framework and the Foundation (o-c) Framework share the same functional interfaces, if you want to mix the two frameworks, the "no overhead bridge" is required ";
Here we use the NSAID array for example:
Convert the Core Foundation type to the Foundation Type
CFArrayRef x; // NSArray * array = (_ bridge NSArray *) x; // array = CFBridgingRelease (x );
When using the first conversion method, the object ownership is not converted, but only forced conversion. Objects need to be manually released;
When using the second conversion method, convert the object ownership and transfer the object ownership to the ARC without manual release.
Convert the Foundation type to the Core Foundation type
NSArray * array = nil; // method 1 CFArrayRef arrayRef = (_ bridge CFArrayRef) array; // method 2 arrayRef = CFBridgingRetain (array );
The two methods are also the first one that does not convert the object ownership, or is the Foundation object, so it is automatically released.
Second, the ownership of the conversion object needs to be manually released (CFRelease (arrayRef );)