Instance Method

execute(_:)

Executes a save request and returns success or failure.

Declaration

func execute(_ saveRequest: CNSaveRequest) throws

Parameters

saveRequest

The save request to execute.

error

Error information, if an error occurred.

Return Value

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

Discussion

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.

See Also

Fetching Contacts

func enumerateContacts(with: CNContactFetchRequest, usingBlock: (CNContact, UnsafeMutablePointer<ObjCBool>) -> Void)

Returns a Boolean value that indicates whether the enumeration of all contacts matching a contact fetch request executed successfully.

func unifiedMeContactWithKeys(toFetch: [CNKeyDescriptor]) -> CNContact

Fetches the unified contact that is the "me" card.

func unifiedContact(withIdentifier: String, keysToFetch: [CNKeyDescriptor]) -> CNContact

Fetches a unified contact for the specified contact identifier.

func unifiedContacts(matching: NSPredicate, keysToFetch: [CNKeyDescriptor]) -> [CNContact]

Fetches all unified contacts matching the specified predicate.