gpt4 book ai didi

ios - 我如何解码 UIPasteboard 类型 "apple web archive pasteboard"网页内容,并将其与 evernote api 同步?

转载 作者:行者123 更新时间:2023-11-29 13:11:36 25 4
gpt4 key购买 nike

首先,我尝试从 UIPasteboard 获取 webResourceData:

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"];

}

然后,我尝试用这些数据创建一个 not:

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 看到的是附件而不是网页内容...

最佳答案

要显示网页内容,您需要将其嵌入 ENML ,您不需要将其添加到资源中。这是一个简单的例子:

<?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>

关于ios - 我如何解码 UIPasteboard 类型 "apple web archive pasteboard"网页内容,并将其与 evernote api 同步?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17202844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com