Platforms to show: All Mac Windows Linux Cross-Platform

Back to CNContactStoreMBS class.

CNContactStoreMBS.allContacts(byref error as NSErrorMBS) as CNContactMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Searches all contacts.

Same as ContactsWithFetchRequest function with key list from CNContactStoreMBS.AllFetchKeys function.

CNContactStoreMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
The constructor.

CNContactStoreMBS.ContactsWithFetchRequest(fetchRequest as CNContactFetchRequestMBS, byref error as NSErrorMBS) as CNContactMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Returns all contacts matching a contact fetch request.

fetchRequest: The contact fetch request that specifies the search criteria.
error: Error information, if an error occurred.

This method waits until the enumeration is finished. If there are no results, the method returns an empty array.
This can be used to fetch all contacts without keeping all of them at once in memory because this is expensive.

Your app must be code signed to see contacts.

Some examples using this method:

CNContactStoreMBS.containersMatchingPredicate(predicate as NSPredicateMBS, byref error as NSErrorMBS) as CNContainerMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Fetches all containers matching the specified predicate.

predicate: The predicate to use to fetch matching containers. Set this property to nil to match all containers.
error: Error information, if an error occurred.

Returns an array of CNContainer objects that match the predicate.

A container holds a collection of contacts, a contact (each contact can be in only one container). CardDAV accounts usually have only one container of contacts. Exchange accounts may have multiple containers, where each container represents an Exchange folder.

This method returns an empty array when no matching container is found. In case of an error this method returns nil. You should use only the predicates defined CNContainer class. Compound predicates are not supported.

CNContactStoreMBS.defaultContainerIdentifier as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Returns the identifier of the default container.

This identifier can be used to fetch a default container. A default container is where the user wants new contacts to be added implicitly.

Some examples using this method:

CNContactStoreMBS.Destructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
The destructor.

CNContactStoreMBS.enumerateContactsWithFetchRequest(fetchRequest as CNContactFetchRequestMBS, byref error as NSErrorMBS, tag as Variant = nil) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Returns a Boolean value that indicates whether the enumeration of all contacts matching a contact fetch request executed successfully.

fetchRequest: The contact fetch request that specifies the search criteria.
error: Error information, if an error occurred.

Calls enumerateContactsWithFetchRequest event for each contact found.

Returns true if enumeration of all contacts matching a contact fetch request executes successfully; otherwise, false.

This method waits until the enumeration is finished. If there are no results, the event is not called and the method returns true.

This can be used to fetch all contacts without keeping all of them at once in memory because this is expensive.

See also:

CNContactStoreMBS.enumeratorForChangeHistoryFetchRequest(request as CNChangeHistoryFetchRequestMBS, byref error as NSErrorMBS) as CNFetchResultMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 22.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Enumerate a change history fetch request.

Executes the given fetch request and returns an enumerator for the results.
This may prevent all events from being loaded into memory at once.

An exception may be thrown if an error occurs during enumeration.

request: A description of the events to fetch.
error: If the fetch fails, contains an NSErrorMBS object with more information.

Returns an enumerator of the events matching the result, or nil if there was an error.

Some examples using this method:

CNContactStoreMBS.enumeratorForContactFetchRequest(request as CNContactFetchRequestMBS, byref error as NSErrorMBS) as CNFetchResultMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 22.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Enumerate a contact fetch request.

Executes the given fetch request and returns an enumerator for the results.
This may prevent all records from being loaded into memory at once.

An exception may be thrown if an error occurs during enumeration.

request: A description of the records to fetch.
error: If the fetch fails, contains an NSErrorMBS object with more information.

An enumerator of the records matching the result, or nil if there was an error.

CNContactStoreMBS.executeSaveRequest(saveRequest as CNSaveRequestMBS, byref Error as NSErrorMBS) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Executes a save request and returns success or failure.

saveRequest: The save request to execute.
error: Error information, if an error occurred.

Returns true if the save request executes successfully; otherwise, false.

It is recommended that you do not access objects in the save request from other threads when it is in the process of being executed, because it may modify the contacts in the process. A save request only applies the changes to the objects. If there are overlapping changes with multiple or concurrent CNSaveRequest then the last saved change wins.

Warning: Do not use in macOS 10.11 or earlier due to bugs, which have been fixed in macOS 10.12.

Some examples using this method:

CNContactStoreMBS.groupsByName(name as String, byref error as NSErrorMBS) as CNGroupMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Looks for groups with matching names.

Returns empty array if nothing found.
Comparison is localized case insensitive.

CNContactStoreMBS.groupsForContact(contact as CNContactMBS, byref error as NSErrorMBS) as CNGroupMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Searches all groups for a given contact.

CNContactStoreMBS.groupsMatchingPredicate(predicate as NSPredicateMBS, byref error as NSErrorMBS) as CNGroupMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Fetches all groups matching the specified predicate.

predicate: The predicate to use to fetch the matching groups. Set predicate to nil to match all groups.
error: Error information, if an error occurred.

Returns an array of CNGroup objects that match the predicate.

This method returns an empty array when no matching groups are found. If an error occurs, this method returns nil. You should use only the predicates defined in CNGroup class predicates. Compound predicates are not supported. Contacts may be members of one or more groups, depending upon the account they come from.

CNContactStoreMBS.requestAccessForEntityType(entityType as Integer = 0, tag as Variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Requests access to the user's contacts.

entityType: Set to CNEntityTypeContacts.

Users are able to grant or deny access to contact data on a per-application basis. Request access to contact data by calling requestAccessForEntityType method. This will not block your application while the user is being asked for permission. The user will only be prompted the first time access is requested; any subsequent CNContactStore calls will use the existing permissions. The requestAccessForEntityType event is later called. This method is optional when CNContactStore is used in the background thread. If this method is not used, CNContactStore may block your application while the user is asked for access permission.

Your app must be code signed to see contacts.

See also:

Some examples using this method:

CNContactStoreMBS.unifiedContactsMatchingPredicate(predicate as NSPredicateMBS, byref error as NSErrorMBS) as CNContactMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Fetches all unified contacts matching the specified predicate.

predicate: The predicate to match against.
error: Error information, if an error occurred.

Returns an array of CNContact objects matching the predicate.

If no matches are found, this method returns an empty array (or nil in case of error). Use only the predicates from the CNContact class predicates. Compound predicates are not supported by this method. Due to unification, the returned contacts may have different identifiers than you specify. To fetch all contacts, use enumerateContactsWithFetchRequest.

Same as other unifiedContactsMatchingPredicate function with key list from CNContactStoreMBS.AllFetchKeys function.

See also:

Some examples using this method:

CNContactStoreMBS.unifiedContactsMatchingPredicate(predicate as NSPredicateMBS, keysToFetch() as CNKeyDescriptorMBS, byref error as NSErrorMBS) as CNContactMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Fetches all unified contacts matching the specified predicate.

predicate: The predicate to match against.
keys: The properties to fetch in the returned CNContact objects. You should fetch only the properties that you plan to use. Note that you can combine contact keys and contact key descriptors.
error: Error information, if an error occurred.

Returns an array of CNContact objects matching the predicate.

If no matches are found, this method returns an empty array (or nil in case of error). Use only the predicates from the CNContact class predicates. Compound predicates are not supported by this method. Due to unification, the returned contacts may have different identifiers than you specify. To fetch all contacts, use enumerateContactsWithFetchRequest.

See also:

CNContactStoreMBS.unifiedContactWithIdentifier(identifier as string, byref error as NSErrorMBS) as CNContactMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Fetches a unified contact for the specified contact identifier.

identifier: The identifier of the contact to fetch.
error: Error information, if an error occurred.

Returns an unified contact matching or linked to the identifier.

Due to unification, the returned contact may have a different identifier, than you specify. To fetch a batch of contacts by identifiers use predicateForContactsWithIdentifiers with unifiedContactsMatchingPredicate. It is recommended to fetch only the properties that will be used. You can combine contact keys and contact key descriptors together.

Same as other unifiedContactWithIdentifier function with key list from CNContactStoreMBS.AllFetchKeys function.

See also:

Some examples using this method:

CNContactStoreMBS.unifiedContactWithIdentifier(identifier as string, keys() as CNKeyDescriptorMBS, byref error as NSErrorMBS) as CNContactMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Fetches a unified contact for the specified contact identifier.

identifier: The identifier of the contact to fetch.
keys: The properties to fetch in the returned CNContact object.
error: Error information, if an error occurred.

Returns an unified contact matching or linked to the identifier.

Due to unification, the returned contact may have a different identifier, than you specify. To fetch a batch of contacts by identifiers use predicateForContactsWithIdentifiers with unifiedContactsMatchingPredicate. It is recommended to fetch only the properties that will be used. You can combine contact keys and contact key descriptors together.

See also:

CNContactStoreMBS.unifiedMeContact(byref error as NSErrorMBS) as CNContactMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 18.4 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Queries an unified contact for the user.
Example
dim ContactStore as CNContactStoreMBS // your store
Dim error As NSErrorMBS
Dim contact As CNContactMBS = ContactStore.unifiedMeContact(Error)

If contact <> nil then
MsgBox contact.familyName
Else
MsgBox "No contact?"
End If

Same as unifiedMeContactWithKeysToFetch function with key list from CNContactStoreMBS.AllFetchKeys function.

CNContactStoreMBS.unifiedMeContactWithKeysToFetch(keys() as CNKeyDescriptorMBS, byref error as NSErrorMBS) as CNContactMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Contacts MBS Mac64bit Plugin 16.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Queries an unified contact for the user.

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


The biggest plugin in space...