Question

I want to pre-fill core data from plist. got that sorted. anyway in order to NOT pre fill core data WHEN iCloud has the data allrdy. how do i check for that ? i'm useing Magical Record to import and handle my Core Data+iCloud and it works

either i miss some step somewhere or i don't know. it imports and checks if there is a value allrdy if there is it doesn't import. i hope it works in local storage but as soon as i turn on iCloud it gets messy

i found this but it doesn't work for me. i'm not sure it's the right way to do it .Some how i think i need to first check if iCloud is enabled then if there's content or i'm i totally wrong here ?

NSURL *ubiq = [[NSFileManager defaultManager]
                   URLForUbiquityContainerIdentifier:nil];
    if (ubiq) {
        NSLog(@"iCloud access at %@", ubiq);
}
else {
NSlog(@"No iCloud")
}
Was it helpful?

Solution

Check that:

- (BOOL) iCloudCheckContent{

    NSString* backupName = @"myBackup";
    NSError *error = nil;
    NSFileManager *filemanager = [NSFileManager defaultManager];    
    NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];

    if (ubiq == nil) {
        NSlog(@"No iCloud");
        return NO;
    }

    bool ret = [filemanager startDownloadingUbiquitousItemAtURL:[[ubiq URLByAppendingPathComponent:@"Documents" isDirectory:true] URLByAppendingPathComponent:backupName] error:&error];

    NSLog(@"Started for %@ %d", backupName, ret);

    if (error != nil) {
        NSLog(@"iCloud error: %@", [error localizedDescription]);
    }

    return ret;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top