在 Evernote SDK 上访问标签

Accessing Tags on Evernote SDK

我已成功下载带有示例项目中的以下片段的注释。

[[ENSession sharedSession] downloadNote:self.noteRef progress:^(CGFloat progress) {
    if (self.webView) {

    }
} completion:^(ENNote *note, NSError *downloadNoteError) {
    if (note && self.webView) {
        self.note = note;
        NSLog(@"%@", self.note.title);
        NSLog(@"%@", self.note.sourceUrl);

        NSLog(@"%lu", self.note.EDAMNote.tagNames.count);
        NSLog(@"%lu", self.note.tagNames.count);
        [self loadWebDataFromNote:note];
    } else {
        NSLog(@"Error downloading note contents %@", downloadNoteError);
    }
}];

虽然标题正确,但返回的 tagNames 数组为 nil。

有没有办法根据笔记检索tagNames?

干杯

您可以使用下面的代码获取标签 guid 列表。

ENSession * session = [ENSession sharedSession];
ENNoteStoreClient * noteStoreClient = [session noteStoreForNoteRef:noteRef];
[noteStoreClient getNoteWithGuid:noteRef.guid withContent:YES withResourcesData:NO withResourcesRecognition:NO withResourcesAlternateData:NO success:^(EDAMNote *note) {
    NSLog(@"tags guids: %@", note.tagGuids);
} failure:^(NSError *error) {

}];

然后获取Evernote标签列表并获取它们的名称。

我叫Eric Cheng。我是 Evernote iOS SDK

的首席工程师

读这个 https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/evernote-sdk-ios/ENSDK/ENNote.h#L57-L63

我提供了 ENNote class 作为 EDAMNote 的简化版本,它是 Evernote 笔记的 thrift class 代表。 ENNote 做的事情很简单,让开发人员更容易理解。如果您想阅读笔记上的标签,您应该使用此处列出的 EDAM API https://github.com/evernote/evernote-cloud-sdk-ios/blob/master/evernote-sdk-ios/ENSDK/Advanced/ENNoteStoreClient.h#L518-L528

你可以这样写代码:

ENSession * session = [ENSession sharedSession];
ENNoteStoreClient * noteStoreClient = [session noteStoreForNoteRef:noteRef];
[noteStoreClient getNoteTagNamesWithGuid:noteRef.guid success:^(NSArray *tags) {
        NSLog(@"Tag count: %@", [tags count]);
  } failure:^(NSError *error) {
        NSLog(@"Error in fetching tags %@ for note guid %@", error, noteRef.guid);
}];