Using The
                         Address Book
                or: How I Learned To Stop Worrying And Love
              ...
Why use the
                                 Address Book?
                         • Using the address book gives you an ...
Two Frameworks
                    • AddressBook allows for direct
                         manipulation of the address bo...
AddessBook
                    • Four basic data types: Address books,
                         Records, Single-value prop...
Address Books

                    • Stored as an ABAddressBookRef.
                    • Used to get information about an...
AddressBook
                                   Functions
                         • ABAddressBookCreate: Create a new addr...
Records
                    •    Both people and groups are stored as ABRecordRef’s.

                    •    Find out th...
Group Records
                    •    ABGroupCreate

                    •    ABGroupCopyArrayOfAllMembers

             ...
Person Records
                    •    ABPersonCreate

                    •    ABPersonGetTypeOfProperty

              ...
Person Properties
                   kABPersonFirstNameProperty
                   kABPersonLastNameProperty
             ...
Displaying Names
                    • ABRecordCopyCompositeName will return a
                         string for a group...
Getting Records
                    • ABAddressBookGetGroupWithRecordID &
                         ABAddressBookGetPersonW...
Single Value
                                Properties
                    • Pass a property name and a value.
          ...
Example!
                         #import <AddressBook/AddressBook.h>




Tuesday, March 3, 2009
Multivalue
                                     properties
                    • Things like phone numbers, email
        ...
Mutable Multivalue
                             Properties
                    • ABMultiValueCreateMutableCopy to create
 ...
Another Example!




Tuesday, March 3, 2009
Street Addresses
                    • Multivalue of dictionaries.
                    • Each address component is a key/v...
Street Address
                            Example




Tuesday, March 3, 2009
AddressBookUI
                    • View controllers for many common
                         address book related functio...
Picking People
                    • ABPeoplePickerNavigationController
                          presents a very similar ...
Viewing/Editing
                                Person Records
                    • ABPersonViewController will display a...
Creating New
                            Person Records
                    • ABNewPersonViewController allows users to
  ...
Unknown Person
                             Controller
                    • Add to or create a new person with
          ...
Loading...




Tuesday, March 3, 2009
Using




Tuesday, March 3, 2009
Contact Me

                    • Collin Donnell (iPhone Developer)
                    • Email: collindonnell@gmail.com
 ...
Upcoming SlideShare
Loading in …5
×

Using the Addressbook

9,519 views

Published on

Collin Donnell - Using the Addressbook. Non Game App Dev Track. 360|iDev San Jose '09

Published in: Technology, Business
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
9,519
On SlideShare
0
From Embeds
0
Number of Embeds
72
Actions
Shares
0
Downloads
151
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Using the Addressbook

  1. 1. Using The Address Book or: How I Learned To Stop Worrying And Love The Address Book Tuesday, March 3, 2009
  2. 2. Why use the Address Book? • Using the address book gives you an easy way to access and use data your users already have. • Make up for things Contacts can’t do. • Extend what your existing application can do. Tuesday, March 3, 2009
  3. 3. Two Frameworks • AddressBook allows for direct manipulation of the address book. • AddressBookUI Set of view controllers which allow picking, adding new, editing, or viewing contacts. Tuesday, March 3, 2009
  4. 4. AddessBook • Four basic data types: Address books, Records, Single-value properties, and Multivalue properties. • C based, follows Core Foundation rules for memory management. Tuesday, March 3, 2009
  5. 5. Address Books • Stored as an ABAddressBookRef. • Used to get information about and edit the address book directly. • One per thread. • Changes must be saved. Tuesday, March 3, 2009
  6. 6. AddressBook Functions • ABAddressBookCreate: Create a new address book. • ABAddressBookSave: Commit any changes that you’ve made to the address book. • ABAddressBookRevert: Throw away unsaved changes. • ABAddressBookAddRecord: Add or remove a record from the address book. Both take an ABRecordRef. • ABAddressBookRegisterExternalCallBack: Use to receive a call when the address book is changed by another app, or another thread in your app. Tuesday, March 3, 2009
  7. 7. Records • Both people and groups are stored as ABRecordRef’s. • Find out the type by using the function ABRecordGetRecordType, which returns an kABGroupType or kABPersonType. • Do not pass a record address threads, ask for the records identifier and use that instead. • Use ABRecordGetRecordID to get the unique ID from a group or person record. • ABRecordCopyValue, ABRecordSetValue, ABRecordRemoveValue are used to copy, set, or remove values from records. Tuesday, March 3, 2009
  8. 8. Group Records • ABGroupCreate • ABGroupCopyArrayOfAllMembers • ABGroupCopyArrayOfAllMembersWithSortOrdering • ABGroupAddRecord, and ABGroupRemoveRecord • ABAddressBookCopyArrayOfAllMembers Tuesday, March 3, 2009
  9. 9. Person Records • ABPersonCreate • ABPersonGetTypeOfProperty • ABPersonCopyLocalizedPropertyName • ABPersonHasImageData, ABPersonCopyImageData, ABPersonRemoveImageData, and ABPersonSetImageData • ABAddressBookComparePeopleByName • ABAddressBookCopyPeopleWithName Tuesday, March 3, 2009
  10. 10. Person Properties kABPersonFirstNameProperty kABPersonLastNameProperty kABPersonMiddleNameProperty kABPersonPrefixProperty kABPersonSuffixProperty kABPersonNicknameProperty kABPersonFirstNamePhoneticProperty kABPersonLastNamePhoneticProperty kABPersonMiddleNamePhoneticProperty kABPersonOrganizationProperty kABPersonJobTitleProperty kABPersonDepartmentProperty kABPersonEmailProperty kABPersonBirthdayProperty kABPersonNoteProperty kABPersonCreationDateProperty kABPersonModificationDateProperty kABPersonAddressProperty Tuesday, March 3, 2009
  11. 11. Displaying Names • ABRecordCopyCompositeName will return a string for a group or person record with the correct formatting. • ABPersonCompositeNameFormat can be used to determine first name or last name first name format. • ABPersonGetSortOrdering tells if people records should be sorted by first or last name. Tuesday, March 3, 2009
  12. 12. Getting Records • ABAddressBookGetGroupWithRecordID & ABAddressBookGetPersonWithRecordID are used to get group or person records when you have the ID. • You can ask the how many peopleABAddressBookGetPersonCount or groups there are by using ABAddressBookGetGroupCount & • ABAddressBookCopyArrayOfAllGroups • ABAddressBookCopyArrayOfAllPeople Tuesday, March 3, 2009
  13. 13. Single Value Properties • Pass a property name and a value. • Example: ABRecordSetValue(person, kABPersonFirstNameProperty, CFSTR(“First Name”), &error); Tuesday, March 3, 2009
  14. 14. Example! #import <AddressBook/AddressBook.h> Tuesday, March 3, 2009
  15. 15. Multivalue properties • Things like phone numbers, email addresses, where a single contact may have multiple. • List of values, each of which has a text label and an identifier. • Functions used to read are, ABMultiValueCopyLabelAtIndex ABMultiValueCopyValueAtIndex ABMultiValueCopyArrayOfAllValues ABMultiValueGetIndexForIdentifier ABMultiValueGetIdentifierAtIndex Tuesday, March 3, 2009
  16. 16. Mutable Multivalue Properties • ABMultiValueCreateMutableCopy to create a mutable copy of a multivalue property. • ABMultiValueCreateMutable to construct your own. • Functions for editing mutable multivalue properties ABMultiValueAddValueAndLabel ABMultiValueInsertValueAndLabelAtIndex ABMultiValueReplaceValueAtIndex ABMultiValueRemoveValueAndLabelAtIndex Tuesday, March 3, 2009
  17. 17. Another Example! Tuesday, March 3, 2009
  18. 18. Street Addresses • Multivalue of dictionaries. • Each address component is a key/value pair. Tuesday, March 3, 2009
  19. 19. Street Address Example Tuesday, March 3, 2009
  20. 20. AddressBookUI • View controllers for many common address book related functions. • 4 controllers: • ABPeoplePickerNavigationController • ABPersonViewController • ABNewPersonViewController • ABUnknownPersonViewController Tuesday, March 3, 2009
  21. 21. Picking People • ABPeoplePickerNavigationController presents a very similar view to Contacts. • Present as a modal view controller and implement the delegate methods. ABPeoplePickerNavigationControllerDelegate Methods peoplePickerNavigationControllerDidCancel: peoplePickerNavigationController:shouldContinueAfterSelectingPerson: peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier: Tuesday, March 3, 2009
  22. 22. Viewing/Editing Person Records • ABPersonViewController will display and allow editing of person records. • Will call personViewController:shouldPerformDefaultActionForPerson:property:identifier: On its delegate when the user taps a property. Tuesday, March 3, 2009
  23. 23. Creating New Person Records • ABNewPersonViewController allows users to create new people and add them to the database with almost no code. • When finished, it will call newPersonViewController:didCompleteWithNewPerson: Tuesday, March 3, 2009
  24. 24. Unknown Person Controller • Add to or create a new person with existing data. • Create person with known information, use setDisplayedPerson: • Will call unknownPersonViewController:didResolveToPerson: on it’s delegate when finished. Tuesday, March 3, 2009
  25. 25. Loading... Tuesday, March 3, 2009
  26. 26. Using Tuesday, March 3, 2009
  27. 27. Contact Me • Collin Donnell (iPhone Developer) • Email: collindonnell@gmail.com • Twitter: collindonnell Tuesday, March 3, 2009

×