2

在模拟器/iPhone 5 中,我有一些从 Facebook 导入的联系人。现在我正在尝试使用 iPhone 通讯簿框架来阅读这些配置文件。不幸的是,它没有返回任何东西。下面是我目前正在使用的代码片段,

ABRecordRef person = ABAddressBookGetPersonWithRecordID(ABAddressBookCreate(), (ABRecordID)recordId)
ABMultiValueRef social = ABRecordCopyValue((__bridge ABRecordRef)person, kABPersonSocialProfileProperty);
//the count of 'social' is empty event there is a Facebook profile is attached to the contact.
if (social) {
    for (int i = 0 ; i < ABMultiValueGetCount(social); i++) {
         NSDictionary *socialDict = (NSDictionary *)ABMultiValueCopyValueAtIndex(social, i);
         NSString* service = [socialDict valueForKey:(NSString *)kABPersonSocialProfileServiceKey];
         NSString* username = [socialDict valueForKey:(NSString *)kABPersonSocialProfileUsernameKey];
         NSLog(@"service... %@, username... %@", service, username);
    }
}
CFRelease(social);

任何帮助表示赞赏。

4

0 回答 0