ABRecordCopyValue return 0 ?

余生长醉 提交于 2019-12-04 05:41:36

问题


What I trying to do, is get all contacts and relies if the contact have SocialProfileProperty or not, after get all this contacts that have SocialProfileProperty I will make simple filtration to know if it is Facebook,Twitter,..

Before I post this question I west full day trying to find any solution for this problem ??

But it is allows return 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);

回答1:


It is allows return 0 ,until the user marge the Social contacts with native and this does

not happened until he try to delete the Facebook account for example in that case alert appear

and ask if u wanna to marge contacts or not ??? other wise return 0 values :)

So this method will never work until the user marge the FaceBook Contacts with native contacts.



来源:https://stackoverflow.com/questions/14605512/abrecordcopyvalue-return-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!