Question

in my app i want write document on iCloud, but i have a problem with one iCloud account, this is the scenario: iCloud Account A, all works perfectly, i can write and read, with iPad and iPhone. iCloud Account B, same as above, i can write and read. iCloud Account C, doens't work, i can't write and read and give me the error.

This is a scratch of code:

NSURL *ubiqContainer = [[NSFileManager defaultManager]
                                URLForUbiquityContainerIdentifier:nil];
        NSURL *ubiquitousPackage = [[ubiqContainer
                                     URLByAppendingPathComponent:@"Documents"]
                                    URLByAppendingPathComponent:kFILENAME];
        MyDocument *mydoc = [[MyDocument alloc]
                                  initWithFileURL:ubiquitousPackage];
        self.mydoc = mydoc;

        [mydoc saveToURL:[mydoc fileURL]
      forSaveOperation:UIDocumentSaveForCreating
     completionHandler:
         ^(BOOL success) {
             //success is always FALSE for the Account C
         }];

then i have implemented this method:

- (void) handleError:(NSError *)error userInteractionPermitted:(BOOL)userInteractionPermitted{
    NSLog(@"error: %@", [error description]);
    NSLog(@"permitted: %d", userInteractionPermitted);
}

and this is the log:

error: Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x15ef24f0 {NSFileNewItemLocationKey=file:///private/var/mobile/Applications/2A1F6A00-AA50-4D44-AFA1-89D0CA747EBB/tmp/(A%20Document%20Being%20Saved%20By%20My%20App)/MyApp.esd, NSFileOriginalItemLocationKey=file:///private/var/mobile/Library/Mobile%20Documents/EAYDD3QH5Q~com~mycompany~My-App/Documents/MyApp.esd, NSUnderlyingError=0x15e3c870 "The operation couldn’t be completed. (Cocoa error 4.)", NSURL=file:///private/var/mobile/Library/Mobile%20Documents/EAYDD3QH5Q~com~mycompany~My-App/Documents/MyApp.esd}
2013-10-20 16:53:24.358 My App[222:3707] permitted: 1

i can't understand why doens't work on this account, and on the other works...what is wrong? i have reinstalled all profiles in the device with the account problem, but doesn't work, any idea?

Was it helpful?

Solution

I fix the problem deleting the iCloud folder of the app, using the command go to Folder in the Finder:

Users/"username"/.Library/Mobile Documents/"app folder"

and then here i delete the folder, in this way i fix the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top