Note that there are some explanatory texts on larger screens.

plurals
  1. POABAddressBook external callback not called in iOS
    text
    copied!<p>I have a class holding the list of contacts of my user in an iPhone app. </p> <p>The core of it is implemented as follows. </p> <pre><code>//file Contacts.m //imports here void MyAddressBookExternalChangeCallback ( ABAddressBookRef addressBook, CFDictionaryRef info, void *context ) { NSLog(@"callback called "); [[Contacts sharedInstance] refresh]; } @implementation Contacts @synthesize addressBook; + (Contacts*)sharedInstance { @synchronized(self) { if (sharedInstance == nil) { sharedInstance = [[Contacts alloc] init]; } } return sharedInstance; } - (void)refresh { ABAddressBookRevert(addressBook); /*refreshing the address book in case of changes*/ [people release]; people = (NSArray*)ABAddressBookCopyArrayOfAllPeople(addressBook); } - (id)init { if ((self = [super init])) { sharedInstance = self; addressBook = ABAddressBookCreate();; people = nil; [self refresh]; ABAddressBookRegisterExternalChangeCallback ( addressBook, MyAddressBookExternalChangeCallback, self ); } return sharedInstance; } </code></pre> <p>In <code>init</code>, I setup an external callback <code>MyAddressBookExternalChangeCallback</code> to be notified of changes to the contact list. The problem that I have is that the external callback is not called (I never see the result of the nslog message) when I add a contact in the iPhone phone app. </p> <p>What did I do wrong ? </p> <p>Added note: even stranger, if I do</p> <pre><code>ABAddressBookRevert(addressBook); </code></pre> <p>every time my app come to the front and the address book has been modified, then the callback is called. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload