SimonTheDiver
SimonTheDiver

Reputation: 1187

How do i find the number of members of a CNGroup in Xcode 7/ iOS 9

I want to display the names of each of the CNGroups in an iPhone's contacts database, and the number of people in each group.

I have the array of CNGroups, so I can get the name and the identifier properties of each group

I could call

[CNContact predicateForContactsInGroupWithIdentifier: theGroup.identifier] ,

then create a fetch on the CNContactStore using that predicate and then count the number of elements of the array that is returned and that works.

That seems a long winded and processor intensive way of finding out the number of members, so much so that I'm sure there must be a easier way to achieve this.

Have I missed something or is this the way it has to be done?

Thanks.

Upvotes: 1

Views: 476

Answers (1)

Steve Wilford
Steve Wilford

Reputation: 9012

That would be how I would do it, if you're finding it to be hitting performance you could always dispatch it onto a background queue since according to the documentation

this framework is optimized for thread-safe, read-only usage

Upvotes: 1

Related Questions