Search code examples
macosdelegatessyncservices

MACOSX - When calling -finishSyncing on an ISyncSessionDriver the app makes repeated calls to the delegate


I'm using Sync Services in my application. I'm using the normal way of getting the contacts from the address book (using sync services).

I want to prematurely end a sync session if the user decides to do that, therefore, when the user presses the "cancel" button, I make a call to [driver finishSyncing]

Attached to the ISyncSessionDriver is a delegate which deals with delegate methods typical of a sync session. One of those methods is - (BOOL)sessionDriver:(ISyncSessionDriver *)sender willFinishSessionAndReturnError:(NSError **)outError

The problem is that when calling finishSyncing, the sessionDriver:willFinishSessionAndReturnError: gets repeatedly called, not just once, but hunderds of times. Eventually it will throw an error.

So, how could I fix this, or what better debugging can I do to figure out what the problem is?

Thanks


Solution

  • Use instead - (void)cancelSyncing.

    Make sure to release the receiver soon afterward because you cannot continue using a canceled session.