2013-06-19 10 views
1

첫째, 내가 UIPasteboard에서 webResourceData을 얻으려고 :UIPasteboard 유형 "apple web archive pasteboard"웹 콘텐츠를 디코딩하고 evernote api와 동기화하려면 어떻게해야합니까?

if ([[pasteboard pasteboardTypes] containsObject:@"Apple Web Archive pasteboard type"]) { 
    NSData* archiveData = [[UIPasteboard generalPasteboard] valueForPasteboardType:@"Apple Web Archive pasteboard type"]; 
    if (archiveData) 
    { 
     if (DEBUG) [self checkPasteboard]; 
     NSError* error = nil; 
     id webArchive = [NSPropertyListSerialization propertyListWithData:(NSData *)archiveData options:NSPropertyListImmutable format:NULL error:&error]; 
     if (error) { 
      //TODO: 
      DLog(@"format error!"); 
     } 
     NSDictionary* webMainResource = [webArchive objectForKey:@"WebMainResource"]; 
     NSData * webResourceData = [dic objectForKey:@"WebResourceData"]; 

    } 

} 다음

, 난이 데이터와하지를 만들려고는 :

NSData *dataHash = [webResourceData enmd5]; 
EDAMData *edamData = [[EDAMData alloc] initWithBodyHash:dataHash size:webResourceData.length body:webResourceData]; 
EDAMResource* resource = [[EDAMResource alloc] initWithGuid:nil noteGuid:nil data:edamData mime:@"text/html" width:0 height:0 duration:0 active:0 recognition:0 attributes:nil updateSequenceNum:0 alternateData:nil]; 
NSString *noteContent = [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;\">Hello Evernote.</span>" 
         "</en-note>"]; 
NSMutableArray* resources = [NSMutableArray arrayWithArray:@[resource]]; 
EDAMNote *newNote = [[EDAMNote alloc] initWithGuid:nil title:@"Test note" content:noteContent contentHash:nil contentLength:noteContent.length created:0 updated:0 deleted:0 active:YES updateSequenceNum:0 notebookGuid:nil tagGuids:nil resources:resources attributes:nil tagNames:nil]; 
[[EvernoteNoteStore noteStore] setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { 
    DLog(@"Total bytes written : %lld , Total bytes expected to be written : %lld",totalBytesWritten,totalBytesExpectedToWrite); 
}]; 
[[EvernoteNoteStore noteStore] createNote:newNote success:^(EDAMNote *note) { 
    DLog(@"Note created successfully."); 
    //TODO: need delete the cell 

} failure:^(NSError *error) { 
    DLog(@"Error creating note : %@",error); 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                message:[error.userInfo objectForKey:@"NSLocalizedDescription"] 
                delegate:nil 
              cancelButtonTitle:@"OK" 
              otherButtonTitles:nil]; 
    [alert show]; 
}]; 

문제는 내가 무엇을 할 수 있습니다 Evernote에서 볼 수 있지만 첨부 파일은 웹 콘텐츠가 아닙니다 ...

답변

1

웹 콘텐츠를 표시하려면에 퍼가 야합니다., 자원에 추가 할 필요가 없습니다. 다음은 간단한 예입니다.

<?xml version='1.0' encoding='utf-8'?> 
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"> 
<en-note> 
    <h1> 
    Simple HTML note 
    </h1> 
</en-note> 
+0

죄송합니다. 어디에 HTML을 넣어야합니까? 내 HTML에 에서 HTML을 포함하려고 노력하지만 난 오류가 어떤 종류의 – zolibra

+0

ENML [여기] (에 대한 자세한 내용은이 있어요 http://dev.evernote.com/start/core/enml.php), dtd는 [here] (http://xml.evernote.com/pub/enml2.dtd)입니다. – Mustafa