我想要做的是获取所有联系人并依赖该联系人是否具有SocialProfileProperty,在获取所有具有SocialProfileProperty的联系人后,我将进行简单过滤以了解它是否是Facebook、Twitter、..
在我发布这个问题之前,我整天都在试图找到任何解决这个问题的方法??
但它允许返回 0 ??
ABAddressBookRef addressBook;
CFErrorRef *erer = NULL;
addressBook = ABAddressBookCreateWithOptions(NULL, erer);
CFArrayRef _allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex _nPeople = ABAddressBookGetPersonCount(addressBook);
NSMutableArray *socialArray = [[NSMutableArray alloc] init];
ABMultiValueRef socialProfiles;
for (int i=0;i<_nPeople; i++) {
ABRecordRef _person=CFArrayGetValueAtIndex( _allPeople,i);
NSNumber *recordId = [NSNumber numberWithInteger:ABRecordGetRecordID(_person)];
NSLog(@"%@",recordId);
socialProfiles = ABRecordCopyValue(_person, kABPersonSocialProfileProperty);
if (ABMultiValueGetCount(socialProfiles)>0) {
[socialArray addObject:(__bridge id)(socialProfiles)];
}
}
NSLog(@"%d",socialArray.count);