在simulator / 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);
任何帮助表示感谢。