无法从icloud下载整个sqlite文件

时间:2012-11-22 07:34:03

标签: file sqlite icloud

嗨,我已经将一个sqlite3文件上传到了icloud。现在我想将此文件下载到我的APP的Document文件夹中。按下下载按钮后,将显示成功信息。但事实上,文档文件夹中没有sqlite文件,或者文件可能已损坏。有人能帮助我吗?

-(IBAction)downloadPressed:(id)sender
{
    if(![self downloadFileIfNotAvailable:self.icloudURL])
    {
        [self displayAlert:@"Warning!!" withmessage:@"failed to restore"];
    }else{
        [self displayAlert:@"Congratulations" withmessage:@"restore sccuessfully"];
    }
}

-(BOOL)downloadFileIfNotAvailable:(NSURL *)file
{
    NSNumber*  isIniCloud = nil;
    NSError* err;
    if ([file getResourceValue:&isIniCloud forKey:NSURLIsUbiquitousItemKey error:nil]) {
        // If the item is in iCloud, see if it is downloaded.
        if ([isIniCloud boolValue]) {
            NSFileManager* fm = [NSFileManager defaultManager];
            if([fm removeItemAtPath:self.filePath error:&err])
            {
                if (![fm startDownloadingUbiquitousItemAtURL:file error:nil]) {
                    return NO;
                }else{
                    return YES;
                }
            }
        }
        return NO;
    }
    return NO;
}

0 个答案:

没有答案