在iOS 6中,此代码始终为Nil
提供NSLog
,但第一个始终提供正确的复合名称。因此我知道我可以访问地址簿,如果我在addressbook
中更改名称,代码会记录正确的复合名称。无论我投放了多少封电子邮件,联系人ABMultiValueGetCount
始终为Nil
。这是为什么?
ABRecordRef person = (__bridge ABRecordRef)[addressBookArray objectAtIndex:x];
NSLog(@"%@ -", ABRecordCopyCompositeName(person));
NSLog(@"%ld -", ABMultiValueGetCount(ABRecordCopyValue(person, kABPersonEmailProperty)));
答案 0 :(得分:2)
得到它......看起来像我应该预期的某种managedObjectContext条件......
在一个View Controller中,我这样做了:
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
addressBookArray = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
// Prsented info on the user name, but not on the Emails
CFRelease(addressBook);
在第二个视图控制器中,我传递了addressBookArray以尝试保存一些周期然后执行此操作:
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
// Successfully accessed name properties (suspect they were chached some where ?
// Unsuccsfully accessed email properties (they have never been accessed so no chache and I get Null
CFRelease(addressBook);
修复...在secondviewController中重复:
addressBookArray = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
Bingo问题解决了!!
答案 1 :(得分:1)
请检查以下链接。那些可以解决你的问题。在ios6中,苹果已经改变了地址簿的许可。
App crashed in iOS 6 when user changes Contacts access permissions