SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
Using The
                         Address Book
                or: How I Learned To Stop Worrying And Love
                              The Address Book




Tuesday, March 3, 2009
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
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
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
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
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
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
Group Records
                    •    ABGroupCreate

                    •    ABGroupCopyArrayOfAllMembers

                    •    ABGroupCopyArrayOfAllMembersWithSortOrdering

                    •    ABGroupAddRecord, and ABGroupRemoveRecord

                    •    ABAddressBookCopyArrayOfAllMembers




Tuesday, March 3, 2009
Person Records
                    •    ABPersonCreate

                    •    ABPersonGetTypeOfProperty

                    •    ABPersonCopyLocalizedPropertyName

                    •    ABPersonHasImageData, ABPersonCopyImageData,
                         ABPersonRemoveImageData, and ABPersonSetImageData

                    •    ABAddressBookComparePeopleByName

                    •    ABAddressBookCopyPeopleWithName




Tuesday, March 3, 2009
Person Properties
                   kABPersonFirstNameProperty
                   kABPersonLastNameProperty
                   kABPersonMiddleNameProperty
                   kABPersonPrefixProperty
                   kABPersonSuffixProperty
                   kABPersonNicknameProperty
                   kABPersonFirstNamePhoneticProperty
                   kABPersonLastNamePhoneticProperty
                   kABPersonMiddleNamePhoneticProperty
                   kABPersonOrganizationProperty
                   kABPersonJobTitleProperty
                   kABPersonDepartmentProperty
                   kABPersonEmailProperty
                   kABPersonBirthdayProperty
                   kABPersonNoteProperty
                   kABPersonCreationDateProperty
                   kABPersonModificationDateProperty
                   kABPersonAddressProperty
Tuesday, March 3, 2009
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
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
Single Value
                                Properties
                    • Pass a property name and a value.
                    • Example:
                         ABRecordSetValue(person,
                         kABPersonFirstNameProperty,
                         CFSTR(“First Name”), &error);



Tuesday, March 3, 2009
Example!
                         #import <AddressBook/AddressBook.h>




Tuesday, March 3, 2009
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
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
Another Example!




Tuesday, March 3, 2009
Street Addresses
                    • Multivalue of dictionaries.
                    • Each address component is a key/value pair.




Tuesday, March 3, 2009
Street Address
                            Example




Tuesday, March 3, 2009
AddressBookUI
                    • View controllers for many common
                         address book related functions.
                    • 4 controllers:
                         •   ABPeoplePickerNavigationController

                         •   ABPersonViewController

                         •   ABNewPersonViewController

                         •   ABUnknownPersonViewController


Tuesday, March 3, 2009
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
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
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
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
Loading...




Tuesday, March 3, 2009
Using




Tuesday, March 3, 2009
Contact Me

                    • Collin Donnell (iPhone Developer)
                    • Email: collindonnell@gmail.com
                    • Twitter: collindonnell


Tuesday, March 3, 2009

Weitere ähnliche Inhalte

Mehr von John Wilker

Internationalizing Your Apps
Internationalizing Your AppsInternationalizing Your Apps
Internationalizing Your AppsJohn Wilker
 
Optimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessOptimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessJohn Wilker
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On RailsJohn Wilker
 
Integrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeIntegrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeJohn Wilker
 
Starting Core Animation
Starting Core AnimationStarting Core Animation
Starting Core AnimationJohn Wilker
 
P2P Multiplayer Gaming
P2P Multiplayer GamingP2P Multiplayer Gaming
P2P Multiplayer GamingJohn Wilker
 
Using Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessUsing Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessJohn Wilker
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder BehindJohn Wilker
 
Mobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchMobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchJohn Wilker
 
Accelerometer and OpenGL
Accelerometer and OpenGLAccelerometer and OpenGL
Accelerometer and OpenGLJohn Wilker
 
Deep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkDeep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkJohn Wilker
 
NSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateNSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateJohn Wilker
 
From Flash to iPhone
From Flash to iPhoneFrom Flash to iPhone
From Flash to iPhoneJohn Wilker
 
Managing And Optimizing Memory Usage
Managing And Optimizing Memory UsageManaging And Optimizing Memory Usage
Managing And Optimizing Memory UsageJohn Wilker
 
Web or SDK Development
Web or SDK DevelopmentWeb or SDK Development
Web or SDK DevelopmentJohn Wilker
 
Three Hello Worlds
Three Hello WorldsThree Hello Worlds
Three Hello WorldsJohn Wilker
 
Multi player iPhone Games
Multi player iPhone GamesMulti player iPhone Games
Multi player iPhone GamesJohn Wilker
 
Creation of an iPhone Game
Creation of an iPhone GameCreation of an iPhone Game
Creation of an iPhone GameJohn Wilker
 

Mehr von John Wilker (20)

Internationalizing Your Apps
Internationalizing Your AppsInternationalizing Your Apps
Internationalizing Your Apps
 
Optimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application ResponsivenessOptimizing Data Caching for iPhone Application Responsiveness
Optimizing Data Caching for iPhone Application Responsiveness
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On Rails
 
Integrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLimeIntegrating Push Notifications in your iPhone application with iLime
Integrating Push Notifications in your iPhone application with iLime
 
Starting Core Animation
Starting Core AnimationStarting Core Animation
Starting Core Animation
 
P2P Multiplayer Gaming
P2P Multiplayer GamingP2P Multiplayer Gaming
P2P Multiplayer Gaming
 
Using Concurrency To Improve Responsiveness
Using Concurrency To Improve ResponsivenessUsing Concurrency To Improve Responsiveness
Using Concurrency To Improve Responsiveness
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
Mobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouchMobile WebKit Development and jQTouch
Mobile WebKit Development and jQTouch
 
Accelerometer and OpenGL
Accelerometer and OpenGLAccelerometer and OpenGL
Accelerometer and OpenGL
 
Deep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and FrameworkDeep Geek Diving into the iPhone OS and Framework
Deep Geek Diving into the iPhone OS and Framework
 
NSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegateNSNotificationCenter vs. AppDelegate
NSNotificationCenter vs. AppDelegate
 
Using SQLite
Using SQLiteUsing SQLite
Using SQLite
 
From Flash to iPhone
From Flash to iPhoneFrom Flash to iPhone
From Flash to iPhone
 
Managing And Optimizing Memory Usage
Managing And Optimizing Memory UsageManaging And Optimizing Memory Usage
Managing And Optimizing Memory Usage
 
Web or SDK Development
Web or SDK DevelopmentWeb or SDK Development
Web or SDK Development
 
Three Hello Worlds
Three Hello WorldsThree Hello Worlds
Three Hello Worlds
 
Multi player iPhone Games
Multi player iPhone GamesMulti player iPhone Games
Multi player iPhone Games
 
Creation of an iPhone Game
Creation of an iPhone GameCreation of an iPhone Game
Creation of an iPhone Game
 
Becoming Indie
Becoming IndieBecoming Indie
Becoming Indie
 

Kürzlich hochgeladen

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Kürzlich hochgeladen (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Using the Addressbook

  • 1. Using The Address Book or: How I Learned To Stop Worrying And Love The Address Book Tuesday, March 3, 2009
  • 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. 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. 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. 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. 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. 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. Group Records • ABGroupCreate • ABGroupCopyArrayOfAllMembers • ABGroupCopyArrayOfAllMembersWithSortOrdering • ABGroupAddRecord, and ABGroupRemoveRecord • ABAddressBookCopyArrayOfAllMembers Tuesday, March 3, 2009
  • 9. Person Records • ABPersonCreate • ABPersonGetTypeOfProperty • ABPersonCopyLocalizedPropertyName • ABPersonHasImageData, ABPersonCopyImageData, ABPersonRemoveImageData, and ABPersonSetImageData • ABAddressBookComparePeopleByName • ABAddressBookCopyPeopleWithName Tuesday, March 3, 2009
  • 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. 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. 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. Single Value Properties • Pass a property name and a value. • Example: ABRecordSetValue(person, kABPersonFirstNameProperty, CFSTR(“First Name”), &error); Tuesday, March 3, 2009
  • 14. Example! #import <AddressBook/AddressBook.h> Tuesday, March 3, 2009
  • 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. 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
  • 18. Street Addresses • Multivalue of dictionaries. • Each address component is a key/value pair. Tuesday, March 3, 2009
  • 19. Street Address Example Tuesday, March 3, 2009
  • 20. AddressBookUI • View controllers for many common address book related functions. • 4 controllers: • ABPeoplePickerNavigationController • ABPersonViewController • ABNewPersonViewController • ABUnknownPersonViewController Tuesday, March 3, 2009
  • 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. 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. 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. 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
  • 27. Contact Me • Collin Donnell (iPhone Developer) • Email: collindonnell@gmail.com • Twitter: collindonnell Tuesday, March 3, 2009