4

1)我将一些 csv 文件逐一保存在我的印象笔记中,但我希望所有文件都在一个笔记本下。目前我在默认笔记本下保存笔记,但我想创建一个笔记本,然后我想将我的笔记保存在那个笔记本中

我想要这样

2)目前我正在将该csv文件转换为数据,以便在再次显示csv文件后显示一些附件

但是如何将文件直接保存到evernote而不将其转换为数据?我正在使用以下代码

NSData *NewdataHash = [NewFileData md5];
    EDAMData *NewedamData = [[EDAMData alloc] initWithBodyHash:NewdataHash size:NewFileData.length body:NewFileData];
    EDAMResource* Newresource = [[EDAMResource alloc] initWithGuid:nil noteGuid:nil data:NewedamData mime:@"application/csv" width:0 height:0 duration:0 active:0 recognition:0 attributes:nil updateSequenceNum:0 alternateData:nil];
    NSString *NewnoteContent = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                                  "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
                                  "<en-note>"
                                  "<span style=\"font-weight:bold;\">CountDown DairiesList.</span>"
                                  "<br />"
                                  "<span>Evernote logo :</span>"
                                  "<br />"
                                  "%@"
                                  "</en-note>",[ENMLUtility mediaTagWithDataHash:NewdataHash mime:@"application/csv"]];

    NSMutableArray* Newresources = [NSMutableArray arrayWithArray:@[Newresource]];

    EDAMNote *NewnewNote = [[EDAMNote alloc] initWithGuid:nil title:@"DairiesList CSV" content:NewnoteContent contentHash:nil contentLength:NewnoteContent.length created:0 updated:0 deleted:0 active:YES updateSequenceNum:0 notebookGuid:nil tagGuids:nil resources:Newresources attributes:nil tagNames:nil];
    [[EvernoteNoteStore noteStore] createNote:NewnewNote success:^(EDAMNote *note)
     {   

       }  

      failure:^(NSError *error) {
 }];
4

2 回答 2

2
 EDAMNotebook* notebook = [[EDAMNotebook alloc] initWithGuid:nil name:eObj.title updateSequenceNum:0 defaultNotebook:NO serviceCreated:0 serviceUpdated:0 publishing:nil published:NO stack:nil sharedNotebookIds:nil sharedNotebooks:nil businessNotebook:nil contact:nil restrictions:nil]; 

[noteStore createNotebook:notebook success:^(EDAMNotebook *notebook)  
{
 NSData *NewdataHash = [NewFileData md5];
    EDAMData *NewedamData = [[EDAMData alloc] initWithBodyHash:NewdataHash size:NewFileData.length body:NewFileData];
    EDAMResource* Newresource = [[EDAMResource alloc] initWithGuid:nil noteGuid:nil data:NewedamData mime:@"application/csv" width:0 height:0 duration:0 active:0 recognition:0 attributes:nil updateSequenceNum:0 alternateData:nil];
    NSString *NewnoteContent = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                                  "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
                                  "<en-note>"
                                  "<span style=\"font-weight:bold;\">CountDown DairiesList.</span>"
                                  "<br />"
                                  "<span>Evernote logo :</span>"
                                  "<br />"
                                  "%@"
                                  "</en-note>",[ENMLUtility mediaTagWithDataHash:NewdataHash mime:@"application/csv"]];

    NSMutableArray* Newresources = [NSMutableArray arrayWithArray:@[Newresource]];
                                   EDAMNote *newNote = [[EDAMNote alloc] initWithGuid:notebook.guid title:titileString content:noteContent contentHash:nil contentLength:noteContent.length created:0 updated:0 deleted:0 active:YES updateSequenceNum:notebook.updateSequenceNum notebookGuid:notebook.guid tagGuids:nil resources:resources attributes:nil tagNames:nil];

                                  [[EvernoteNoteStore noteStore] createNote:newNote success:^(EDAMNote *note)
                                   {
                                       NSLog(@"Note created successfully.");


                                   } failure:^(NSError *error) {
                                       NSLog(@"Error creating note : %@",error);
                                   }];


  }
                 failure:^(NSError *error)
                  {

                      NSLog(@"Error : %@",error);
                   }];
于 2013-04-17T05:20:57.957 回答
1

要将笔记保存在笔记本中,只需设置您创建notebookGuid的对象的 。EDAMNote您需要转换为 NSData 来存储 csv 文件。

于 2013-04-13T07:27:24.977 回答