Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

CNContactStoreMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class Contacts MBS Mac64bit Plugin 16.3 Yes No No Yes, macOS only No
Function: The CNContactStore class is a thread-safe class that can fetch and save contacts, groups, and containers.
The CNContactStore class provides ways to execute fetch and save requests. There are a few recommended ways you can implement these requests in your app to load contacts:

  • Fetch only the contact properties that will be used.
  • When fetching all contacts and caching the results, first fetch all contacts identifiers, then fetch batches of detailed contacts by identifiers as required.
  • To aggregate several contacts fetches, first collect a set of unique identifiers from the fetches. Then fetch batches of detailed contacts by those unique identifiers.
  • If you cache the fetched contacts, groups, or containers, you need to refetch these objects (and release the old cached objects) when CNContactStoreDidChangeNotification is posted.

Because CNContactStore fetch methods perform I/O, it’s recommended that you avoid using the main thread to execute fetches.

Your app must be code signed to see contacts.

Feedback, Comments & Corrections

Contact Types

Constant Value Description
CNEntityTypeContacts 0 Contacts

Error Codes

Constant Value Description
CNErrorCodeAuthorizationDenied 100 Authentication denied error.
CNErrorCodeCommunicationError 1 Communication error.
CNErrorCodeContainmentCycle 202 Code containment cycle error.
CNErrorCodeContainmentScope 203 Code containment scope error.
CNErrorCodeDataAccessError 2 Data access error.
CNErrorCodeInsertedRecordAlreadyExists 201 Record already exists.
CNErrorCodeParentRecordDoesNotExist 204 The contact does not exist error.
CNErrorCodePolicyViolation 500 Policy validation error.
CNErrorCodePredicateInvalid 400 Invalid predicate error.
CNErrorCodeRecordDoesNotExist 200 Record not found.
CNErrorCodeValidationConfigurationError 302 Configuration validation error.
CNErrorCodeValidationMultipleErrors 300 Multiple validation error.
CNErrorCodeValidationTypeMismatch 301 Type mismatch validation error.

This class has no sub classes.

Some examples which use this class:

The items on this page are in the following plugins: MBS Mac64bit Plugin.

CNContactRelationMBS   -   CNContactsUserDefaultsMBS

MBS Xojo blog