nenosinc / iCloudDocumentSync

Integrate iCloud into iOS document projects with one-line code methods. Sync, upload, manage, and remove documents from iCloud quickly and easily. Helps to make iCloud "just work" for developers too.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delete All Files is not working

Tejas-narola opened this issue · comments

We have one feature of iCloud backup. When I try to delete all file after upload file, it is working perfectly but when I try to delete all files after downloading file, delete is not working.

Download code:

[[iCloud sharedCloud] retrieveCloudDocumentWithName:filename completion:^(UIDocument *cloudDocument, NSData *documentData, NSError *error) {
    if (!error)  {
        NSData *fileData = documentData;
        NSError *err = nil;
        NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:fileData options:0 error:&err];
        [cloudDocument closeWithCompletionHandler:^(BOOL success) {
            if (success) {
            }
        }];
    }
}];

Delete all Files from iCloud:

[[[iCloud sharedCloud]listCloudFiles] enumerateObjectsUsingBlock:^(NSString *listname, NSUInteger idx, BOOL *stop) {
    if ([listname isKindOfClass:[NSURL class]]) {
        listname = [listname lastPathComponent];
    }

    [[iCloud sharedCloud] deleteDocumentWithName:listname completion:^(NSError *error) {
        if (error) {
        } else {
            [[iCloud sharedCloud] updateFiles];
            int value =   (int)[[iCloud sharedCloud]listCloudFiles].count;
            if (!error && value == 0) {
            } else if(error && value == 1) {
            }
        }
    }];
}];

Any idea what I might be missing?

Please help me out... I've been stuck on this issue for the last two weeks and couldn't find any feasible solution.