Reputation: 73
1) I am saving some csv files in my evernote one by one order but i want all all files under one notebook . At present i am saving notes under default notebook but i want createone notebook and then i want save my notes in that notebook
2) At present i am converting that csv files into data so its showing some attached file after dowing its showing again csv files
But how to save file directly to evernote with out converting it to data? I am using following code
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) {
}];
Upvotes: 4
Views: 633
Reputation: 73
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);
}];
Upvotes: 2
Reputation: 5347
To save a note in a notebook, simply set the notebookGuid
of the EDAMNote
object that you create. You will need to convert to NSData to store the csv file.
Upvotes: 1