如何创建笔记本并将笔记保存在笔记本中?

时间:2013-04-12 07:51:03

标签: iphone objective-c ios6 evernote

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

i want like this

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) {
 }];

2 个答案:

答案 0 :(得分: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);
                   }];

答案 1 :(得分:1)

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