Instance Method

groups(matching:)

Fetches all groups matching the specified predicate.

Declaration

func groups(matching predicate: NSPredicate?) throws -> [CNGroup]

Parameters

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.

Return Value

An array of CNGroup objects that match the predicate.

Discussion

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.

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.