3

In iOS 6, this code always gives me Nil for the second NSLog, however the first always gives the correct Composite Name. Hence I know I have access to the addressbook, if I change the name in addressbook, the code logs the correct Composite Name. No matter how many emails I put in, the contact ABMultiValueGetCount is always Nil. Why is this?

ABRecordRef person = (__bridge ABRecordRef)[addressBookArray objectAtIndex:x];

NSLog(@"%@ -", ABRecordCopyCompositeName(person));
NSLog(@"%ld -", ABMultiValueGetCount(ABRecordCopyValue(person, kABPersonEmailProperty)));
JoshDM
  • 4,939
  • 7
  • 43
  • 72
Aardvark
  • 608
  • 5
  • 15

2 Answers2

2

Got it ... looks like some sort of managedObjectContext condition I should have anticipated ...

In one View Controller I did this:

ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
addressBookArray = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
// Prsented info on the user name, but not on the Emails
CFRelease(addressBook);

In the second view controller I passed addressBookArray to try and save on some cycles then did this:

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);

The fix ... In the secondviewController repeat:

addressBookArray = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

Bingo problem solved !!

Aardvark
  • 608
  • 5
  • 15
1

Please check following links. Those may solve your problem. In ios6 apple have changed the permission of address book.

App crashed in iOS 6 when user changes Contacts access permissions

iOS 6 Address Book not working?

Community
  • 1
  • 1
Susim Samanta
  • 1,605
  • 1
  • 14
  • 30
  • Thanks, I suspected this - I'll check, but I'm 100% positive I have access to the AB ! Why would the ABRecordCopyCompositeName work if I didn't have access ? – Aardvark Nov 20 '12 at 00:48
  • ran ABAddressBookRequestAccessWithCompletion with a postiive result and still can't see emails :( – Aardvark Nov 20 '12 at 11:24