0

我知道如何从通讯录中获取所有人,ABAddressBookCopyArrayOfAllPeople()但如何获取不同组的列表,更具体地说,如何从某个组获取联系人。

我尝试了运气,kABGroupNameProperty但没有返回组名 - 而是经常(null)和有时是名字。

谢谢

4

1 回答 1

2

我认为这就是你想要的:

CFArrayRef groups = ABAddressBookCopyArrayOfAllGroups(addressBook);
int count = ABAddressBookGetGroupCount(addressBook);
for (int i = 0; i < count; i++) {
    ABRecordRef group = CFArrayGetValueAtIndex(groups, i);
    NSString *name = (__bridge NSString *)(ABRecordCopyValue(group, kABGroupNameProperty));
    if ([name isEqualToString:@"name of group you're looking for"]) {
        CFArrayRef people = ABGroupCopyArrayOfAllMembers(group);
        // do something with people in group
    }
}
于 2013-01-08T23:43:09.510 回答