嗨,谁能告诉我为什么 ABMultiValueGetCount(social) 总是返回 0 count ?所有其他字段完美地从地址簿返回。
我正在尝试查看联系人是否有 Twitter 或 Facebook 活动?我的用户在 AB 中定义了 Twitter 和 Facebook。我可以在那里看到他们!
/* The table view controller ViewDidLoad opened the AddressBook and copied these details into addressBookArray then I closed the reference to the AddressBook */
ABRecordRef person = (__bridge ABRecordRef)[addressBookArray objectAtIndex:indexPath.section];
/* Make sure AddressBook is currently open so we can look at things */
ABAddressBookRef addressBook;
addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
if (addressBook != NULL)
{
NSString *firstName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSString *lastName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
/* If I don't do this person always returns NULL for social */
ABRecordRef who = ABRecordCopyValue(ABAddressBookGetPersonWithRecordID (addressBook, ABRecordGetRecordID(person));
/* ABMultiValueRef social = ABRecordCopyValue(person, kABPersonSocialProfileProperty); - always returns NULL */
ABMultiValueRef social = ABRecordCopyValue(who, kABPersonSocialProfileProperty); // always returns a value
/* C is always 0 even if user has FB/Twitter etc why ? */
CFIndex c = ABMultiValueGetCount(social);
CFRelease (addressBook);
}
我读过这个问题:
但是,如果我编辑 AB 联系人并实际添加 twitter,我仍然没有得到结果。还有另一种解决方法吗?显然,Apple 会这样做,正如联系人应用程序告诉您的那样。