Unable to download the note attachmet using Evernote IOS SDK

三世轮回 提交于 2019-12-25 02:25:57

问题


I have integrated the latest evernote ios sdk from github, That support both regular user and also business user. I can able to list the note book and notes without any issues but when i try to download the note attachment its giving me the following error.

Error Domain=ENErrorDomain Code=1 "Missing result: getResourceData failed: unknown result" UserInfo=0x10dcb15f0 {NSLocalizedDescription=Missing result: getResourceData failed: unknown result} Skipping field: due to type mismatch (received:11)

Here the code i have used to download the note attachment.

+ (void)downloadDataWithNoteBook:(ENNotebook *)notebook fromNoteResource:(EDAMResource *)resource
onCompletion:(ZIdResultBlock)block {        
    ENPreferencesStore *preference = [ENSession sharedSession].preferences;     
    ENNoteStoreClient *noteStoreClient = [preference objectForKey:[SEEvernoteHelper getTitleForNoteAttachments:resource]];

    NSString *str = resource.guid; 
    NSLog(@"GUID = [%@]", resource.guid);
    [noteStoreClient getResourceDataWithGuid:resource.guid success:^(NSData *data) {        
             if(block) {            
                 block(data, nil);      
             }  
     }
     failure:^(NSError *error) {        
         if (block) {           
             block(nil, error);         
     }}];    
}

回答1:


Finally i was able to do it!!!

Here is my code:

//select the file that you want to download from evernote 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    isParentNoteBooks = false;
    if ([SEEvernoteHelper isNoteBookInstance:[self.datasourceObjects objectAtIndex:indexPath.row]]) {
        self.selectedNoteBook = [self.datasourceObjects objectAtIndex:indexPath.row];
        [self fetchAttachmentsForNoteBook:[self.datasourceObjects objectAtIndex:indexPath.row]];
        // set here if  the notebook is business or not.
        if ([SEEvernoteHelper isBussinessNoteBook:self.selectedNoteBook]) {
            isCurrentNoteBookBusiness = YES;
        }
        else{
            isCurrentNoteBookBusiness = NO;
        }
    } else {
        self.selectedFileNameToDownload = [SEEvernoteHelper getTitleForNoteAttachments:[self.datasourceObjects objectAtIndex:indexPath.row]];
        self.selectedResource = [self.datasourceObjects objectAtIndex:indexPath.row];
        [self downloadNoteResultObject:self.selectedResource];

    }
}

//start the download process
- (void)downloadNoteResultObject:(id)resultObject {
    MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    HUD.labelText = kStrDownloadingLabel;
    HUD.detailsLabelText = self.selectedFileNameToDownload;

    __weak __typeof__(self) weakSelf = self;
    [SEEvernoteHelper downloadDataWithNoteBook:self.selectedNoteBook fromNoteResource:resultObject onCompletion:^(id result, NSError *error) {
        if (result) {
            [NSThread syncOnMain:^{
                //save the downloaded data....
                [HUD hide:YES];
            }];
        } else {
            [HUD hide:YES];
            [NSThread syncOnMain:^{
                //error
            }];
        }
    }];
}

//get the download file
+ (void)downloadDataWithNoteBook:(ENNotebook *)notebook fromNoteResource:(EDAMResource *)resource onCompletion:(ZIdResultBlock)block {

    ENNoteStoreClient *noteStoreClient = [[ENSession sharedSession] noteStoreForNotebook:notebook];

    [noteStoreClient getResourceWithGuid:resource.guid withData:YES withRecognition:NO withAttributes:YES withAlternateDate:NO success:^(EDAMResource *resource) {
        if(block) {
            block(resource.data.body, nil);
        }

    } failure:^(NSError *error) {
        NSLog(@"Error : %@",error);
        if (block) {
            block(nil, error);
        }
    }];
}


来源:https://stackoverflow.com/questions/25243353/unable-to-download-the-note-attachmet-using-evernote-ios-sdk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!