Core Data + iCloud: clear data folders for syncing

When you are developing an iCloud app and you have problems with syncing try the above code:


<code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
BOOL cleanUbiquitousFolder = YES;
if (cleanUbiquitousFolder)
{
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtURL:[fileManager URLForUbiquityContainerIdentifier:nil] error:nil];

return NO;
}
// Your app code here.

return YES;
}
</code></pre>
<div>
All you need to do is run it once with "cleanUbiquitousFolder = YES" and the switch it back to NO to resume developing your app.
Credits to apple developer forums...

Leave a Reply

Your email address will not be published. Required fields are marked *