1

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.

SimonTheDiver
  • 1,158
  • 1
  • 11
  • 24

1 Answers1

1

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

Steve Wilford
  • 8,894
  • 5
  • 42
  • 66
  • 1
    no noticeable performance issue - even on main thread on iPhone 5 - data sets shouldn't normally be outrageous large. Also you can do a fetch with a single attribute key rather than have to get and store the entire contact for each contact in the group - it just seems like there should be group.numberOfMembers method in the api – SimonTheDiver Oct 08 '15 at 16:26