Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar issue. The callback would only be called once the first time, but if I went out and made changes to the addressbook a second time, then it would be called multiple times. For me, the problem was the method that held the <code>ABAddressBookRegisterExternalChangeCallback</code> was being called in the appDelegate's <code>applicationWillResignActive:</code> method.</p> <p>The way I was using the addressbook was for a sync setting. The problem was, I was registering the external callback everytime the sync settings were being <em>saved</em>, rather than only when the sync settings were being <em>changed</em>.</p> <p>To illustrate, here is the code I was calling in the appDelegate</p> <pre><code>- (void)saveSettings { NSUserDefaults *syncSettingsData = [NSUserDefaults standardUserDefaults]; [syncSettingsData setObject:[NSNumber numberWithBool:self.isSyncingiPadContacts] forKey:SYNC_IPAD_CONTACTS_TURNED_ON]; [self setAddressBookChanged]; [syncSettingsData synchronize]; } - (void)setAddressBookChanged { if (self.isSyncingiPadContacts) { ABAddressBookRegisterExternalChangeCallback(self.addressBook, addressBookChanged, (__bridge void *)self); } else { ABAddressBookUnregisterExternalChangeCallback(self.addressBook, addressBookChanged, (__bridge void *) self); } } </code></pre> <p>I removed the call to <code>setAddressBookChanged</code> in the <code>saveSettings</code> method, and just had it called when the addressbook was being created (first time set up) and whenever the user changed the sync settings.</p> <p>Hopefully this helps you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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